Class: Ruckus::TimeT

Inherits:
Number show all
Defined in:
lib/ruckus/time_t.rb

Constant Summary

Constants inherited from Number

Number::BASERX

Constants inherited from Parsel

Parsel::VERBOTEN

Instance Attribute Summary

Attributes inherited from Number

#ascii, #endian, #pad, #radix, #value, #width

Attributes inherited from Parsel

#name, #parent, #rendered_offset, #rendering, #tag, #value

Instance Method Summary collapse

Methods inherited from Number

#ascii_capture, #ascii_to_s, #capture, #odd_width?, #odd_width_capture, #odd_width_first?, #odd_width_to_s, #resolve, #size, #span_bits, #span_offset, #to_s

Methods inherited from Parsel

bytes_for_bits, coerce, #each_matching_selector, endian?, factory?, #find_containing, #find_tag, #find_tag_struct, #fixup, #in, #incomplete!, #index_for_selectors, #inspect, #matches_selector?, #method_missing, #native?, native?, #next, #out, #parent_structure, #permute, #prev, #resolve, #respond_to?, #root, #size, #visit, #where_am_i?

Constructor Details

#initialize(opts = {}) ⇒ TimeT

Returns a new instance of TimeT.



4
5
6
7
# File 'lib/ruckus/time_t.rb', line 4

def initialize(opts={})
  opts[:width] ||= 32
  super(opts)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ruckus::Parsel

Instance Method Details

#local(*args) ⇒ Object



18
19
20
# File 'lib/ruckus/time_t.rb', line 18

def local(*args)
  @value=( t=Time.local(*args)).to_i
end

#timeObject



22
23
24
# File 'lib/ruckus/time_t.rb', line 22

def time
  Time.at(@value)
end

#to_human(indent = "") ⇒ Object



9
10
11
# File 'lib/ruckus/time_t.rb', line 9

def to_human(indent="")
  "#{indent}#{@name} = #{@value.to_hex} (#{time})"
end

#utc(*args) ⇒ Object Also known as: gm



13
14
15
# File 'lib/ruckus/time_t.rb', line 13

def utc(*args)
  @value=( Time.utc(*args) ).to_i
end