Class: BGPView::Prefixes

Inherits:
Object
  • Object
show all
Defined in:
lib/bgpview/prefixes.rb

Constant Summary collapse

@@cache =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number) ⇒ Prefixes

Returns a new instance of Prefixes.



13
14
15
16
17
18
19
20
21
22
# File 'lib/bgpview/prefixes.rb', line 13

def initialize(number)
  BGPView::Number.check(number)

  prefixes = BGPView::API.call("asn/#{number}/prefixes")

  @ipv4 = extract_ip(prefixes, 'ipv4')
  @ipv6 = extract_ip(prefixes, 'ipv6')

  @@cache[number] = self
end

Instance Attribute Details

#ipv4Object (readonly)

Returns the value of attribute ipv4.



11
12
13
# File 'lib/bgpview/prefixes.rb', line 11

def ipv4
  @ipv4
end

#ipv6Object (readonly)

Returns the value of attribute ipv6.



11
12
13
# File 'lib/bgpview/prefixes.rb', line 11

def ipv6
  @ipv6
end

Class Method Details

.find(number) ⇒ Object



24
25
26
# File 'lib/bgpview/prefixes.rb', line 24

def self.find(number)
  @@cache.key?(number) ? @@cache[number] : new(number)
end