Module: Irrc::Subquery
- Included in:
- Query
- Defined in:
- lib/irrc/subquery.rb
Instance Method Summary collapse
-
#add_child(query) ⇒ Object
Public: Add a child Query object.
-
#ancestor_object?(object) ⇒ Boolean
Public: Returns true if object is listed in ancestor IRR objects.
-
#ancestor_objects ⇒ Object
Public: Returns the IRR object to query including those from ancestor query objects.
-
#children ⇒ Object
Public: Returns child Query objects.
-
#delete_child(query) ⇒ Object
Public: Delete a child Query object.
-
#fork(object) ⇒ Object
Public: Generate a child query to resolve IRR / Whois object recursively.
-
#parent ⇒ Object
Public: Returns the parent (associated) Query object, which is probably as-set.
-
#parent=(query) ⇒ Object
Public: Set a parent (associated) Query object, which is probably as-set.
-
#root ⇒ Object
Public: Returns the root IRR object of the nested query.
-
#root? ⇒ Boolean
Public: Returns true if the query is root.
Instance Method Details
#add_child(query) ⇒ Object
Public: Add a child Query object
30 31 32 |
# File 'lib/irrc/subquery.rb', line 30 def add_child(query) children << query end |
#ancestor_object?(object) ⇒ Boolean
Public: Returns true if object is listed in ancestor IRR objects.
63 64 65 |
# File 'lib/irrc/subquery.rb', line 63 def ancestor_object?(object) ancestor_objects.include?(object) end |
#ancestor_objects ⇒ Object
Public: Returns the IRR object to query including those from ancestor query objects.
Returns: Array of String.
42 43 44 |
# File 'lib/irrc/subquery.rb', line 42 def ancestor_objects @_ancestor_objects ||= Array(parent && parent.ancestor_objects) << object end |
#children ⇒ Object
Public: Returns child Query objects
25 26 27 |
# File 'lib/irrc/subquery.rb', line 25 def children @children ||= [] end |
#delete_child(query) ⇒ Object
Public: Delete a child Query object
35 36 37 |
# File 'lib/irrc/subquery.rb', line 35 def delete_child(query) children.delete(query) end |
#fork(object) ⇒ Object
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)
6 7 8 9 10 |
# 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 ⇒ Object
Public: Returns the parent (associated) Query object, which is probably as-set.
13 14 15 |
# File 'lib/irrc/subquery.rb', line 13 def parent @parent end |
#parent=(query) ⇒ Object
Public: Set a parent (associated) Query object, which is probably as-set.
parent - Parent Query object.
20 21 22 |
# File 'lib/irrc/subquery.rb', line 20 def parent=(query) @parent = query end |
#root ⇒ Object
Public: Returns the root IRR object of the nested query
Returns: String.
49 50 51 52 53 54 55 |
# File 'lib/irrc/subquery.rb', line 49 def root @_root ||= if parent parent.root else self end end |
#root? ⇒ Boolean
Public: Returns true if the query is root.
58 59 60 |
# File 'lib/irrc/subquery.rb', line 58 def root? root == self end |