Class: OSPFv2::LsAge
Class Method Summary collapse
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
Class Method Details
.aging(state = :off) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/ie/ls_age.rb', line 30 def aging(state=:off) case state when :on ; @aging = true when :off ; @aging = false else raise ArgumentError, "Invalid Argument" end end |
.aging? ⇒ Boolean
38 39 40 |
# File 'lib/ie/ls_age.rb', line 38 def aging? @aging end |
Instance Method Details
#-(obj) ⇒ Object
69 70 71 |
# File 'lib/ie/ls_age.rb', line 69 def -(obj) to_i - obj.to_i end |
#<=>(obj) ⇒ Object
65 66 67 |
# File 'lib/ie/ls_age.rb', line 65 def <=>(obj) to_i <=> obj.to_i end |
#aging? ⇒ Boolean
53 54 55 |
# File 'lib/ie/ls_age.rb', line 53 def aging? self.class.aging? end |
#encode ⇒ Object Also known as: enc
77 78 79 |
# File 'lib/ie/ls_age.rb', line 77 def encode [@age].pack('n') end |
#maxaged? ⇒ Boolean
61 62 63 |
# File 'lib/ie/ls_age.rb', line 61 def maxaged? to_i >= OSPFv2::MaxAge end |
#to_hash ⇒ Object
82 83 84 |
# File 'lib/ie/ls_age.rb', line 82 def to_hash to_i end |
#to_i ⇒ Object
49 50 51 |
# File 'lib/ie/ls_age.rb', line 49 def to_i aging? ? (Time.new - @time + @age).to_int : @age end |
#to_s ⇒ Object
73 74 75 |
# File 'lib/ie/ls_age.rb', line 73 def to_s self.class.to_s.split('::').last + ": #{to_i}" end |