class Nokogireader::ReadData

Attributes

parent[R]
text[RW]

Public Class Methods

new(parent_data, definition, node) click to toggle source
# File lib/nokogireader/read_data.rb, line 6
def initialize(parent_data, definition, node)
  @parent = parent_data
  @definition = definition
  @definition.read_attributes.each do |a|
    attributes[a] = node.attribute(a.to_s)
  end
end

Public Instance Methods

[](child_name) click to toggle source
# File lib/nokogireader/read_data.rb, line 40
def [](child_name)
  children[child_name.to_s]
end
add_child(definition, node) click to toggle source
# File lib/nokogireader/read_data.rb, line 22
def add_child(definition, node)
  child = self.class.new(self, definition, node)
  if definition.multiple?
    (children[node.name] ||= []) << child
  else
    children[node.name] = child
  end
  child
end
attributes() click to toggle source
# File lib/nokogireader/read_data.rb, line 14
def attributes
  @attributes ||= {}
end
children() click to toggle source
# File lib/nokogireader/read_data.rb, line 18
def children
  @children ||= {}
end
clear_child_for(node) click to toggle source
# File lib/nokogireader/read_data.rb, line 32
def clear_child_for(node)
  if children[node.name].is_a?(Array)
    children[node.name].pop
  else
    children.delete(node.name)
  end
end
method_missing(name, *args) click to toggle source
Calls superclass method
# File lib/nokogireader/read_data.rb, line 44
def method_missing(name, *args)
  if args.length == 0 && children.key?(name.to_s)
    children[name.to_s]
  else
    super(name, *args)
  end
end