Class: OSPFv2::LsAge
Class Attribute Summary collapse
-
._aging ⇒ Object
Returns the value of attribute _aging.
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
- #reset(age = nil) ⇒ Object
- #to_hash ⇒ Object
- #to_i ⇒ Object
- #to_s ⇒ Object
- #to_s_ios ⇒ Object
Constructor Details
#initialize(age = 0) ⇒ LsAge
Returns a new instance of LsAge.
47 48 49 50 |
# File 'lib/ie/ls_age.rb', line 47 def initialize(age=0) @age=age raise ArgumentError, "Invalid Argument #{age}" unless age.is_a?(Integer) end |
Class Attribute Details
._aging ⇒ Object
Returns the value of attribute _aging.
29 30 31 |
# File 'lib/ie/ls_age.rb', line 29 def _aging @_aging end |
Class Method Details
.aging(arg = nil) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ie/ls_age.rb', line 33 def aging(arg=nil) if arg case arg when :on ; self._aging = true when :off ; self._aging = false end else self._aging = ! _aging end end |
.aging? ⇒ Boolean
30 31 32 |
# File 'lib/ie/ls_age.rb', line 30 def aging? _aging end |
Instance Method Details
#-(obj) ⇒ Object
82 83 84 |
# File 'lib/ie/ls_age.rb', line 82 def -(obj) to_i - obj.to_i end |
#<=>(obj) ⇒ Object
78 79 80 |
# File 'lib/ie/ls_age.rb', line 78 def <=>(obj) to_i <=> obj.to_i end |
#aging? ⇒ Boolean
66 67 68 |
# File 'lib/ie/ls_age.rb', line 66 def aging? self.class.aging? end |
#encode ⇒ Object Also known as: enc
94 95 96 |
# File 'lib/ie/ls_age.rb', line 94 def encode [@age].pack('n') end |
#maxaged? ⇒ Boolean
74 75 76 |
# File 'lib/ie/ls_age.rb', line 74 def maxaged? to_i >= OSPFv2::MaxAge end |
#reset(age = nil) ⇒ Object
61 62 63 64 |
# File 'lib/ie/ls_age.rb', line 61 def reset(age=nil) @age = age if age @time=nil end |
#to_hash ⇒ Object
99 100 101 |
# File 'lib/ie/ls_age.rb', line 99 def to_hash to_i end |
#to_i ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/ie/ls_age.rb', line 52 def to_i if aging? @time ||= Time.now (Time.new - @time + @age).to_int else @age end end |
#to_s ⇒ Object
86 87 88 |
# File 'lib/ie/ls_age.rb', line 86 def to_s self.class.to_s.split('::').last + ": #{to_i}" end |
#to_s_ios ⇒ Object
90 91 92 |
# File 'lib/ie/ls_age.rb', line 90 def to_s_ios "LS age: #{to_i}" end |