Class: Arin::RWS::Network
- Inherits:
-
Object
- Object
- Arin::RWS::Network
- Defined in:
- lib/arin-rws/network.rb
Instance Attribute Summary collapse
-
#end_address ⇒ Object
Returns the value of attribute end_address.
-
#handle ⇒ Object
Returns the value of attribute handle.
-
#name ⇒ Object
Returns the value of attribute name.
-
#registration_date ⇒ Object
Returns the value of attribute registration_date.
-
#start_address ⇒ Object
Returns the value of attribute start_address.
-
#update_date ⇒ Object
Returns the value of attribute update_date.
Instance Method Summary collapse
- #comment ⇒ Object
- #customer ⇒ Object
-
#initialize(data) ⇒ Network
constructor
A new instance of Network.
- #net_blocks ⇒ Object
- #org ⇒ Object
- #origin_as ⇒ Object
Constructor Details
#initialize(data) ⇒ Network
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/arin-rws/network.rb', line 6 def initialize(data) self.name = data['net']['name']['$'] self.handle = data['net']['handle']['$'] self.start_address = data['net']['startAddress']['$'] self.end_address = data['net']['endAddress']['$'] self.update_date = DateTime.parse(data['net']['updateDate']['$']) if not data['net']['registrationDate'].nil? self.registration_date = DateTime.parse(data['net']['registrationDate']['$']) end @netblocks = [] if not data['net']['netBlocks'].nil? t = data['net']['netBlocks']['netBlock'] if t.instance_of? Array t.each do |l| @netblocks << Arin::RWS::NetBlock.new(l) end else @netblocks << Arin::RWS::NetBlock.new(t) end end #@origin_as = [] #data['net']['originASes'].each do |o| # pp o # @origin_as.push(o['originAS']['$']) #end @origin_as = [] if not data['net']['originASes'].nil? t = data['net']['originASes']['originAS'] if t.instance_of? Array t.each do |l| @origin_as << l['$'] end else @origin_as << t['$'] end end if not data['net']['comment'].nil? line = data['net']['comment']['line'] if line.instance_of? Array @comment = "" line.each do |l| @comment << l['$'] << "\n" end else @comment = line['$'] end end if not data['net']['customerRef'].nil? @customer_handle = data['net']['customerRef']['@handle'] end if not data['net']['orgRef'].nil? @org_handle = data['net']['orgRef']['@handle'] end end |
Instance Attribute Details
#end_address ⇒ Object
Returns the value of attribute end_address.
4 5 6 |
# File 'lib/arin-rws/network.rb', line 4 def end_address @end_address end |
#handle ⇒ Object
Returns the value of attribute handle.
4 5 6 |
# File 'lib/arin-rws/network.rb', line 4 def handle @handle end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/arin-rws/network.rb', line 4 def name @name end |
#registration_date ⇒ Object
Returns the value of attribute registration_date.
4 5 6 |
# File 'lib/arin-rws/network.rb', line 4 def registration_date @registration_date end |
#start_address ⇒ Object
Returns the value of attribute start_address.
4 5 6 |
# File 'lib/arin-rws/network.rb', line 4 def start_address @start_address end |
#update_date ⇒ Object
Returns the value of attribute update_date.
4 5 6 |
# File 'lib/arin-rws/network.rb', line 4 def update_date @update_date end |
Instance Method Details
#comment ⇒ Object
80 81 82 |
# File 'lib/arin-rws/network.rb', line 80 def comment @comment end |
#customer ⇒ Object
84 85 86 87 |
# File 'lib/arin-rws/network.rb', line 84 def customer r = Arin::RWS::Client.query("customer/#{@customer_handle}.json") Arin::RWS::Customer.new(r) end |
#net_blocks ⇒ Object
72 73 74 |
# File 'lib/arin-rws/network.rb', line 72 def net_blocks @netblocks end |
#org ⇒ Object
89 90 91 92 |
# File 'lib/arin-rws/network.rb', line 89 def org r = Arin::RWS::Client.query("org/#{@org_handle}.json") Arin::RWS::Org.new(r) end |
#origin_as ⇒ Object
76 77 78 |
# File 'lib/arin-rws/network.rb', line 76 def origin_as @origin_as end |