Class: NicInfo::Ip

Inherits:
Object
  • Object
show all
Defined in:
lib/nicinfo/ip.rb

Overview

deals with RDAP IP network structures

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Ip

Returns a new instance of Ip.



37
38
39
40
41
42
# File 'lib/nicinfo/ip.rb', line 37

def initialize config
  @config = config
  @common = CommonJson.new config
  @entities = Array.new
  @asEventActors = Array.new
end

Instance Attribute Details

#asEventActorsObject

Returns the value of attribute asEventActors.



35
36
37
# File 'lib/nicinfo/ip.rb', line 35

def asEventActors
  @asEventActors
end

#entitiesObject

Returns the value of attribute entities.



35
36
37
# File 'lib/nicinfo/ip.rb', line 35

def entities
  @entities
end

#objectclassObject

Returns the value of attribute objectclass.



35
36
37
# File 'lib/nicinfo/ip.rb', line 35

def objectclass
  @objectclass
end

Instance Method Details

#displayObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/nicinfo/ip.rb', line 50

def display
  @config.logger.start_data_item
  @config.logger.data_title "[ IP NETWORK ]"
  @config.logger.terse "Handle", NicInfo::get_handle( @objectclass ), NicInfo::AttentionType::SUCCESS
  @config.logger.extra "Object Class Name", NicInfo::get_object_class_name( @objectclass )
  @config.logger.terse "Start Address", NicInfo.get_startAddress( @objectclass ), NicInfo::AttentionType::SUCCESS
  @config.logger.terse "End Address", NicInfo.get_endAddress( @objectclass ), NicInfo::AttentionType::SUCCESS
  @config.logger.terse "CIDRs", get_CIDRs
  @config.logger.datum "IP Version", @objectclass[ "ipVersion" ]
  @config.logger.extra "Name", NicInfo.get_name( @objectclass )
  @config.logger.terse "Country", NicInfo.get_country( @objectclass )
  @config.logger.datum "Type", NicInfo.get_type( @objectclass )
  @config.logger.extra "Parent Handle", @objectclass[ "parentHandle" ]
  @common.display_status @objectclass
  @common.display_events @objectclass
  @common.display_as_events_actors @asEventActors
  @common.display_remarks @objectclass
  @common.display_links( get_cn, @objectclass )
  @config.logger.end_data_item
end

#get_CIDRsObject



84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/nicinfo/ip.rb', line 84

def get_CIDRs
  startAddress = NicInfo.get_startAddress @objectclass
  endAddress = NicInfo.get_endAddress @objectclass
  if startAddress and endAddress
    cidrs = find_cidrs(startAddress, endAddress)
    return cidrs.join(', ')
  elsif startAddress
    return NetAddr::CIDR.create(startAddress).to_s
  elsif endAddress
    return NetAddr::CIDR.create(endAddress).to_s
  else
    return ""
  end
end

#get_cnObject



71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/nicinfo/ip.rb', line 71

def get_cn
  handle = NicInfo::get_handle @objectclass
  if !handle
    startAddress = NicInfo.get_startAddress @objectclass
    handle << startAddress if startAddress
    endAddress = NicInfo.get_endAddress @objectclass
    handle << " - " if startAddress and endAddress
    handle << endAddress if endAddress
  end
  return handle if handle
  return "(unidentifiable network #{object_id})"
end

#process(json_data) ⇒ Object



44
45
46
47
48
# File 'lib/nicinfo/ip.rb', line 44

def process json_data
  @objectclass = json_data
  @entities = @common.process_entities @objectclass
  return self
end

#to_nodeObject



99
100
101
# File 'lib/nicinfo/ip.rb', line 99

def to_node
  DataNode.new( get_cn, nil, NicInfo::get_self_link( NicInfo::get_links( @objectclass, @config ) ) )
end