Class: TeamCymru::ASNRecord

Inherits:
Struct
  • Object
show all
Defined in:
lib/teamcymru/asnclient.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#allocObject

Returns the value of attribute alloc

Returns:

  • (Object)

    the current value of alloc



6
7
8
# File 'lib/teamcymru/asnclient.rb', line 6

def alloc
  @alloc
end

#asnObject

Returns the value of attribute asn

Returns:

  • (Object)

    the current value of asn



6
7
8
# File 'lib/teamcymru/asnclient.rb', line 6

def asn
  @asn
end

#ccObject

Returns the value of attribute cc

Returns:

  • (Object)

    the current value of cc



6
7
8
# File 'lib/teamcymru/asnclient.rb', line 6

def cc
  @cc
end

#cidrObject

Returns the value of attribute cidr

Returns:

  • (Object)

    the current value of cidr



6
7
8
# File 'lib/teamcymru/asnclient.rb', line 6

def cidr
  @cidr
end

#dataObject

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



6
7
8
# File 'lib/teamcymru/asnclient.rb', line 6

def data
  @data
end

#ipObject

Returns the value of attribute ip

Returns:

  • (Object)

    the current value of ip



6
7
8
# File 'lib/teamcymru/asnclient.rb', line 6

def ip
  @ip
end

#nicObject

Returns the value of attribute nic

Returns:

  • (Object)

    the current value of nic



6
7
8
# File 'lib/teamcymru/asnclient.rb', line 6

def nic
  @nic
end

#orgObject

Returns the value of attribute org

Returns:

  • (Object)

    the current value of org



6
7
8
# File 'lib/teamcymru/asnclient.rb', line 6

def org
  @org
end

Class Method Details

.from_s(str) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/teamcymru/asnclient.rb', line 10

def ASNRecord::from_s(str)
	args = str.chomp.split(/\|/).map{|x| x.strip}
	if args.length == 7
		args.insert(6,'')
	elsif args.length == 5 # used for AS lookups
		args.insert(2,'')
		args.insert(2,'')
		args.insert(6,'')
	end
	ASNRecord.new(*args)
end

Instance Method Details

#cached=(cached) ⇒ Object



21
22
23
# File 'lib/teamcymru/asnclient.rb', line 21

def cached=(cached)
	@cached = cached
end

#from_cache?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/teamcymru/asnclient.rb', line 24

def from_cache?
	@cached || false
end

#to_sObject



7
8
9
# File 'lib/teamcymru/asnclient.rb', line 7

def to_s
	"#{self.asn.ljust(8)}| #{self.ip.ljust(17)}| #{self.cidr.ljust(20)}| #{self.cc.ljust(3)}| #{self.nic.ljust(9)}| #{self.alloc.ljust(11)}| #{self.data} | #{self.org}"
end