Class: OSPFv2::Color_Tlv
- Defined in:
- lib/lsa/tlv/color.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#tlv_type ⇒ Object
readonly
Returns the value of attribute tlv_type.
Instance Method Summary collapse
- #__parse(s) ⇒ Object
- #encode ⇒ Object
-
#initialize(arg = {}) ⇒ Color_Tlv
constructor
A new instance of Color_Tlv.
- #to_s ⇒ Object
Methods included from Common
#ivar_to_klassname, #ivars, #set, #to_hash
Methods included from SubTlv
Methods included from Tlv
Constructor Details
#initialize(arg = {}) ⇒ Color_Tlv
Returns a new instance of Color_Tlv.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/lsa/tlv/color.rb', line 21 def initialize(arg={}) @tlv_type = 9 @color = 0 if arg.is_a?(Hash) then set(arg.dup) elsif arg.is_a?(String) __parse(arg) else raise ArgumentError, "Invalid argument", caller end end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
19 20 21 |
# File 'lib/lsa/tlv/color.rb', line 19 def color @color end |
#tlv_type ⇒ Object (readonly)
Returns the value of attribute tlv_type.
19 20 21 |
# File 'lib/lsa/tlv/color.rb', line 19 def tlv_type @tlv_type end |
Instance Method Details
#__parse(s) ⇒ Object
38 39 40 |
# File 'lib/lsa/tlv/color.rb', line 38 def __parse(s) @tlv_type, _, @color = s.unpack('nnN') end |
#encode ⇒ Object
34 35 36 |
# File 'lib/lsa/tlv/color.rb', line 34 def encode [@tlv_type, 4, @color].pack('nnN') end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/lsa/tlv/color.rb', line 42 def to_s self.class.to_s + ": " + color.to_s end |