module Irrc::Subquery

Public Instance Methods

add_child(query) click to toggle source

Public: Add a child Query object

# File lib/irrc/subquery.rb, line 30
def add_child(query)
  children << query
end
ancestor_object?(object) click to toggle source

Public: Returns true if object is listed in ancestor IRR objects.

# File lib/irrc/subquery.rb, line 63
def ancestor_object?(object)
  ancestor_objects.include?(object)
end
ancestor_objects() click to toggle source

Public: Returns the IRR object to query including those from ancestor query objects.

Returns: Array of String.

# File lib/irrc/subquery.rb, line 42
def ancestor_objects
  @_ancestor_objects ||= Array(parent && parent.ancestor_objects) << object
end
children() click to toggle source

Public: Returns child Query objects

# File lib/irrc/subquery.rb, line 25
def children
  @children ||= []
end
delete_child(query) click to toggle source

Public: Delete a child Query object

# File lib/irrc/subquery.rb, line 35
def delete_child(query)
  children.delete(query)
end
fork(object) click to toggle source

Public: Generate a child query to resolve IRR / Whois object recursively.

object - IRR / Whois object to extract. (eg: as-set, route-set, aut-num object)

# File lib/irrc/subquery.rb, line 6
def fork(object)
  Query.new(object, source: @sources, protocol: @protocols).tap {|q|
    q.parent = self
  }.tap {|c| self.add_child c }
end
parent() click to toggle source

Public: Returns the parent (associated) Query object, which is probably as-set.

# File lib/irrc/subquery.rb, line 13
def parent
  @parent
end
parent=(query) click to toggle source

Public: Set a parent (associated) Query object, which is probably as-set.

parent - Parent Query object.

# File lib/irrc/subquery.rb, line 20
def parent=(query)
  @parent = query
end
root() click to toggle source

Public: Returns the root IRR object of the nested query

Returns: String.

# File lib/irrc/subquery.rb, line 49
def root
  @_root ||= if parent
               parent.root
             else
               self
             end
end
root?() click to toggle source

Public: Returns true if the query is root.

# File lib/irrc/subquery.rb, line 58
def root?
  root == self
end