Class: BGPView::Peers

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

Constant Summary collapse

@@cache =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number) ⇒ Peers

Returns a new instance of Peers.



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

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

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

  @ipv4 = extract_as(peers, 'ipv4')
  @ipv6 = extract_as(peers, 'ipv6')

  @@cache[number] = self
end

Instance Attribute Details

#ipv4Object (readonly)

Returns the value of attribute ipv4.



10
11
12
# File 'lib/bgpview/peers.rb', line 10

def ipv4
  @ipv4
end

#ipv6Object (readonly)

Returns the value of attribute ipv6.



10
11
12
# File 'lib/bgpview/peers.rb', line 10

def ipv6
  @ipv6
end

Class Method Details

.find(number) ⇒ Object



23
24
25
# File 'lib/bgpview/peers.rb', line 23

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