Class: Object

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

Instance Method Summary collapse

Instance Method Details

#define_to_sObject



104
105
106
107
108
109
110
111
112
# File 'lib/infra/ospf_common.rb', line 104

def define_to_s
  if defined?($style)
    self.class.class_eval { eval("alias :to_s :to_s_#{$style}") }
  elsif respond_to?(:to_s_default)
    self.class.class_eval { alias :to_s :to_s_default }
  else
    puts "You're screwed!"
  end
end

#to_bitstringObject



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

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

#to_shex(*args) ⇒ Object



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

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

#to_shex4_len(len, *args) ⇒ Object



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

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

#to_shex_len(len, *args) ⇒ Object



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

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