Class: OSPFv2::Summary_Base
- Includes:
- CommonMetric
- Defined in:
- lib/lsa/summary.rb,
lib/lsa/summary.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Lsa
Lsa::AdvertisingRouter, Lsa::LsAge, Lsa::LsId, Lsa::MODX
Constants included from Constant
Constant::DATABASE_DESCRIPTION, Constant::HELLO, Constant::LINK_STATE_ACKNOWLEDGEMENT, Constant::LINK_STATE_REQUEST, Constant::LINK_STATE_UPDATE, Constant::V2, Constant::V3
Instance Attribute Summary collapse
-
#metric ⇒ Object
readonly
Returns the value of attribute metric.
-
#mt_metrics ⇒ Object
readonly
Returns the value of attribute mt_metrics.
-
#netmask ⇒ Object
readonly
Returns the value of attribute netmask.
Attributes inherited from Lsa
#advertising_router, #ls_age, #ls_id, #options, #sequence_number
Class Method Summary collapse
Instance Method Summary collapse
- #encode ⇒ Object
-
#initialize(type, arg = {}) ⇒ Summary_Base
constructor
A new instance of Summary_Base.
- #parse(s) ⇒ Object
- #to_hash ⇒ Object
- #to_s_default(*args) ⇒ Object
- #to_s_junos ⇒ Object
- #to_s_junos_verbose ⇒ Object
Methods included from CommonMetric
Methods inherited from Lsa
#<=>, #ack, #encode_header, #encode_request, factory, #find_lsa_from_link, #force_refresh, #header_lsa, #is_acked?, #is_opaque?, #key, #ls_type, #lsdb_link_id, #lsdb_link_id=, #maxage, #maxaged?, #method_missing, new_ntop, #refresh, #retransmit, #to_s_verbose
Methods included from TO_S
Methods included from Common
#ivar_to_klassname, #ivars, #set
Constructor Details
#initialize(type, arg = {}) ⇒ Summary_Base
Returns a new instance of Summary_Base.
40 41 42 43 44 45 46 |
# File 'lib/lsa/summary.rb', line 40 def initialize(type, arg={}) @netmask=nil @metric=nil @mt_metrics=[] @ls_type = LsType.new(type) super arg end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class OSPFv2::Lsa
Instance Attribute Details
#metric ⇒ Object (readonly)
Returns the value of attribute metric.
38 39 40 |
# File 'lib/lsa/summary.rb', line 38 def metric @metric end |
#mt_metrics ⇒ Object (readonly)
Returns the value of attribute mt_metrics.
38 39 40 |
# File 'lib/lsa/summary.rb', line 38 def mt_metrics @mt_metrics end |
#netmask ⇒ Object (readonly)
Returns the value of attribute netmask.
38 39 40 |
# File 'lib/lsa/summary.rb', line 38 def netmask @netmask end |
Class Method Details
.new_hash(hash) ⇒ Object
151 152 153 154 |
# File 'lib/lsa/summary.rb', line 151 def self.new_hash(hash) raise ArgumentError, "Invalid argument" unless hash.is_a?(Hash) new(hash) end |
Instance Method Details
#encode ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/lsa/summary.rb', line 48 def encode @netmask ||= Netmask.new @metric ||= Metric.new summary =[] summary << netmask.encode summary << metric.encode summary << mt_metrics.collect { |x| x.encode } if mt_metrics super summary.join end |
#parse(s) ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/lsa/summary.rb', line 58 def parse(s) netmask, metric, mt_metrics = super(s).unpack('NNa*') @netmask = Netmask.new netmask @metric = Metric.new metric while mt_metrics.size>0 self << MtMetric.new(mt_metrics.slice!(0,4)) end end |
#to_hash ⇒ Object
67 68 69 |
# File 'lib/lsa/summary.rb', line 67 def to_hash super end |
#to_s_default(*args) ⇒ Object
71 72 73 74 |
# File 'lib/lsa/summary.rb', line 71 def to_s_default(*args) super + ['',netmask, metric, *mt_metrics].collect { |x| x.to_s }.join("\n ") end |
#to_s_junos ⇒ Object
81 82 83 |
# File 'lib/lsa/summary.rb', line 81 def to_s_junos super end |
#to_s_junos_verbose ⇒ Object
76 77 78 79 80 |
# File 'lib/lsa/summary.rb', line 76 def to_s_junos_verbose mask = "mask #{netmask.to_ip}" super + ['', mask, metric.to_s_junos, *mt_metrics.collect{|m| m.to_s_junos}].join("\n ") end |