Class: OSPFv2::LsAge
Instance Method Summary collapse
- #-(obj) ⇒ Object
- #<=>(obj) ⇒ Object
- #aging? ⇒ Boolean
- #encode ⇒ Object (also: #enc)
-
#initialize(age = 0) ⇒ LsAge
constructor
A new instance of LsAge.
- #maxage ⇒ Object
- #maxaged? ⇒ Boolean
- #to_hash ⇒ Object
- #to_i ⇒ Object
- #to_s ⇒ Object
Constructor Details
Instance Method Details
#-(obj) ⇒ Object
55 56 57 |
# File 'lib/ie/ls_age.rb', line 55 def -(obj) to_i - obj.to_i end |
#<=>(obj) ⇒ Object
51 52 53 |
# File 'lib/ie/ls_age.rb', line 51 def <=>(obj) to_i <=> obj.to_i end |
#aging? ⇒ Boolean
39 40 41 |
# File 'lib/ie/ls_age.rb', line 39 def aging? true end |
#encode ⇒ Object Also known as: enc
63 64 65 |
# File 'lib/ie/ls_age.rb', line 63 def encode [@age].pack('n') end |
#maxaged? ⇒ Boolean
47 48 49 |
# File 'lib/ie/ls_age.rb', line 47 def maxaged? to_i >= OSPFv2::MaxAge end |
#to_hash ⇒ Object
68 69 70 |
# File 'lib/ie/ls_age.rb', line 68 def to_hash to_i end |
#to_i ⇒ Object
35 36 37 |
# File 'lib/ie/ls_age.rb', line 35 def to_i aging? ? (Time.new - @time + @age).to_int : @age end |
#to_s ⇒ Object
59 60 61 |
# File 'lib/ie/ls_age.rb', line 59 def to_s self.class.to_s.split('::').last + ": #{to_i}" end |