class SML::Time

Attributes

type[RW]
value[RW]

Public Class Methods

construct(array_rep) click to toggle source
# 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
new(type, value) click to toggle source
# File lib/ruby-sml/sml-time.rb, line 8
def initialize(type, value)
  @type = type
  @value = value
end
pconstruct(o={}) click to toggle source
# File lib/ruby-sml/sml-time.rb, line 29
def self.pconstruct(o={})
  return SML::Time.new(o[:type], o[:value])
end

Public Instance Methods

to_a() click to toggle source
# 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