Class: Rex::Proto::Rmi::Model::Element
- Inherits:
-
Object
- Object
- Rex::Proto::Rmi::Model::Element
- Includes:
- Rex::Proto::Rmi::Model
- Defined in:
- lib/rex/proto/rmi/model/element.rb
Direct Known Subclasses
Call, CallData, Continuation, DgcAck, OutputHeader, Ping, PingAck, ProtocolAck, ReturnData, ReturnValue, UniqueIdentifier
Constant Summary
Constants included from Rex::Proto::Rmi::Model
CALL_MESSAGE, DGC_ACK_MESSAGE, MULTIPLEX_PROTOCOL, PING_ACK, PING_MESSAGE, PROTOCOL_ACK, PROTOCOL_NOT_SUPPORTED, RETURN_DATA, RETURN_EXCEPTION, RETURN_VALUE, SIGNATURE, SINGLE_OP_PROTOCOL, STREAM_PROTOCOL
Class Method Summary collapse
- .attr_accessor(*vars) ⇒ Object
-
.attributes ⇒ Array
Retrieves the element class fields.
-
.decode(io) ⇒ Rex::Proto::Rmi::Model::Element
Creates a Rex::Proto::Rmi::Model::Element with data from the IO.
Instance Method Summary collapse
-
#attributes ⇒ Array
Retrieves the element instance fields.
-
#decode(io) ⇒ Rex::Proto::Rmi::Model::Element
Decodes the Rex::Proto::Rmi::Model::Element from the input.
-
#encode ⇒ String
Encodes the Rex::Proto::Rmi::Model::Element into an String.
-
#initialize(options = {}) ⇒ Element
constructor
A new instance of Element.
Constructor Details
#initialize(options = {}) ⇒ Element
Returns a new instance of Element.
35 36 37 38 39 40 41 42 |
# File 'lib/rex/proto/rmi/model/element.rb', line 35 def initialize( = {}) self.class.attributes.each do |attr| if .has_key?(attr) m = (attr.to_s + '=').to_sym self.send(m, [attr]) end end end |
Class Method Details
.attr_accessor(*vars) ⇒ Object
11 12 13 14 15 |
# File 'lib/rex/proto/rmi/model/element.rb', line 11 def self.attr_accessor(*vars) @attributes ||= [] @attributes.concat vars super(*vars) end |
.attributes ⇒ Array
Retrieves the element class fields
20 21 22 |
# File 'lib/rex/proto/rmi/model/element.rb', line 20 def self.attributes @attributes end |
.decode(io) ⇒ Rex::Proto::Rmi::Model::Element
Creates a Rex::Proto::Rmi::Model::Element with data from the IO.
28 29 30 31 32 33 |
# File 'lib/rex/proto/rmi/model/element.rb', line 28 def self.decode(io) elem = self.new elem.decode(io) elem end |
Instance Method Details
#attributes ⇒ Array
Retrieves the element instance fields
47 48 49 |
# File 'lib/rex/proto/rmi/model/element.rb', line 47 def attributes self.class.attributes end |
#decode(io) ⇒ Rex::Proto::Rmi::Model::Element
Decodes the Rex::Proto::Rmi::Model::Element from the input.
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rex/proto/rmi/model/element.rb', line 55 def decode(io) self.class.attributes.each do |attr| dec_method = ("decode_#{attr}").to_sym decoded = self.send(dec_method, io) assign_method = (attr.to_s + '=').to_sym self.send(assign_method, decoded) end self end |
#encode ⇒ String
Encodes the Rex::Proto::Rmi::Model::Element into an String.
70 71 72 73 74 75 76 77 78 |
# File 'lib/rex/proto/rmi/model/element.rb', line 70 def encode encoded = '' self.class.attributes.each do |attr| m = ("encode_#{attr}").to_sym encoded << self.send(m) if self.send(attr) end encoded end |