class JsonInference::NthChildNode

Public Class Methods

new(parent) click to toggle source
Calls superclass method JsonInference::BaseNode::new
# File lib/json-inference/nth_child_node.rb, line 3
def initialize(parent)
  super()
  @parent = parent
end

Public Instance Methods

selector() click to toggle source
# File lib/json-inference/nth_child_node.rb, line 8
def selector
  "#{@parent.selector}:nth-child()"
end
selector_line(documents_count) click to toggle source
# 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) click to toggle source
# 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