Class: JsonInference::NthChildNode
- Inherits:
-
BaseNode
- Object
- BaseNode
- JsonInference::NthChildNode
show all
- Defined in:
- lib/json-inference/nth_child_node.rb
Instance Method Summary
collapse
Methods inherited from BaseNode
#<<, #each_sub_node, #indent, #indent_level
Constructor Details
Returns a new instance of NthChildNode.
3
4
5
6
|
# File 'lib/json-inference/nth_child_node.rb', line 3
def initialize(parent)
super()
@parent = parent
end
|
Instance Method Details
#selector ⇒ Object
8
9
10
|
# File 'lib/json-inference/nth_child_node.rb', line 8
def selector
"#{@parent.selector}:nth-child()"
end
|
#selector_line(documents_count) ⇒ Object
12
13
14
|
# File 'lib/json-inference/nth_child_node.rb', line 12
def selector_line(documents_count)
"#{indent}#{selector}: #{@values.size} child#{'ren' unless @values.size == 1}\n"
end
|
#to_s(documents_count) ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'lib/json-inference/nth_child_node.rb', line 16
def to_s(documents_count)
str = ""
str << selector_line(documents_count)
str << @values.to_s(indent)
each_sub_node do |sub_node|
str << sub_node.to_s(@values.size)
end
str
end
|