Class: ML_ruby::ML_atom

Inherits:
Object
  • Object
show all
Defined in:
lib/ml-ruby/ml_data_types.rb

Direct Known Subclasses

ML_char, ML_char16, ML_int16, ML_int32, ML_int64, ML_int8, ML_uint32

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ ML_atom

Returns a new instance of ML_atom.



21
22
23
# File 'lib/ml-ruby/ml_data_types.rb', line 21

def initialize payload
  @payload= payload
end

Instance Attribute Details

#payloadObject (readonly)

Returns the value of attribute payload.



20
21
22
# File 'lib/ml-ruby/ml_data_types.rb', line 20

def payload
  @payload
end

Class Method Details

.decode(data) ⇒ Object



36
37
38
# File 'lib/ml-ruby/ml_data_types.rb', line 36

def self.decode data
  self.new( data.unpack( self.packstring )[0] )
end

.packstringObject



30
31
32
# File 'lib/ml-ruby/ml_data_types.rb', line 30

def self.packstring
  @packstring
end

.sizeObject



27
28
29
# File 'lib/ml-ruby/ml_data_types.rb', line 27

def self.size
  @size
end

Instance Method Details

#==(other) ⇒ Object



42
43
44
45
# File 'lib/ml-ruby/ml_data_types.rb', line 42

def == other
  false if not other
  @payload== other.payload
end

#encodeObject



33
34
35
# File 'lib/ml-ruby/ml_data_types.rb', line 33

def encode
  [ @payload ].pack self.class.packstring
end

#inspectObject



39
40
41
# File 'lib/ml-ruby/ml_data_types.rb', line 39

def inspect
  "#{self.class.name}: #{@payload}"
end

#sizeObject



24
25
26
# File 'lib/ml-ruby/ml_data_types.rb', line 24

def size
  self.class.size
end