Class: Object

Inherits:
BasicObject
Defined in:
lib/infra/ospf_common.rb

Instance Method Summary collapse

Instance Method Details

#to_bitstringObject



95
96
97
98
99
100
101
# File 'lib/infra/ospf_common.rb', line 95

def to_bitstring
  if self.respond_to?(:encode)
    self.enc.unpack('B*')[0]
  else
    ""
  end
end

#to_shex(*args) ⇒ Object



84
85
86
# File 'lib/infra/ospf_common.rb', line 84

def to_shex(*args)
  self.respond_to?(:encode) ? self.encode(*args).unpack('H*')[0] : ""
end

#to_shex4_len(len, *args) ⇒ Object



91
92
93
94
# File 'lib/infra/ospf_common.rb', line 91

def to_shex4_len(len, *args)
  s = to_shex4(*args)
  "#{s[0..len]}#{s.size>len ? '...' : ''}"
end

#to_shex_len(len, *args) ⇒ Object



87
88
89
90
# File 'lib/infra/ospf_common.rb', line 87

def to_shex_len(len, *args)
  s = to_shex(*args)
  "#{s[0..len]}#{s.size>len ? '...' : ''}"
end