Class: Lib::BOOTP::Packet::Seconds
- Inherits:
-
Object
- Object
- Lib::BOOTP::Packet::Seconds
- Extended by:
- Forwardable
- Includes:
- Comparable
- Defined in:
- lib/lib/bootp/packet/seconds.rb
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(secs = 0) ⇒ Seconds
constructor
A new instance of Seconds.
- #pack ⇒ Object
Constructor Details
#initialize(secs = 0) ⇒ Seconds
Returns a new instance of Seconds.
18 19 20 21 |
# File 'lib/lib/bootp/packet/seconds.rb', line 18 def initialize(secs=0) raise ArgumentError, "Seconds count out of range #{secs}" if secs.to_i < 0 or secs.to_i > 0xFFFF @secs = secs end |
Class Method Details
.unpack(secs) ⇒ Object
31 32 33 |
# File 'lib/lib/bootp/packet/seconds.rb', line 31 def self.unpack(secs) self.new secs.unpack('n').first end |
Instance Method Details
#<=>(other) ⇒ Object
23 24 25 |
# File 'lib/lib/bootp/packet/seconds.rb', line 23 def <=>(other) self.to_i <=> other.to_i end |
#pack ⇒ Object
27 28 29 |
# File 'lib/lib/bootp/packet/seconds.rb', line 27 def pack [@secs.to_i].pack('n') end |