Class: SML::Time
- Inherits:
-
Object
- Object
- SML::Time
- Defined in:
- lib/ruby-sml/sml-time.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type, value) ⇒ Time
constructor
A new instance of Time.
- #to_a ⇒ Object
Constructor Details
#initialize(type, value) ⇒ Time
Returns a new instance of Time.
8 9 10 11 |
# File 'lib/ruby-sml/sml-time.rb', line 8 def initialize(type, value) @type = type @value = value end |
Instance Attribute Details
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/ruby-sml/sml-time.rb', line 6 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/ruby-sml/sml-time.rb', line 6 def value @value end |
Class Method Details
.construct(array_rep) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ruby-sml/sml-time.rb', line 13 def self.construct(array_rep) return nil if array_rep.nil? choice = array_rep.shift array_rep.shift unless choice.nil? type = case choice when 0x01 :seconds_index when 0x02 :timestamp end value = array_rep.shift array_rep.shift unless value.nil? return SML::Time.new(type, value) end |
Instance Method Details
#to_a ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ruby-sml/sml-time.rb', line 33 def to_a choice = case type when :seconds_index 0x01 when :timestamp 0x02 end return [] << choice << :uint8 << value << :uint32 end |