Class: Eggnog::Node

Inherits:
Struct
  • Object
show all
Defined in:
lib/eggnog/node.rb

Constant Summary collapse

CONTENT_ROOT =
"__content__".freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object (private)



78
79
80
# File 'lib/eggnog/node.rb', line 78

def method_missing(m, *args, &block)
  node.send(m, *args, &block)
end

Instance Attribute Details

#nodeObject

Returns the value of attribute node

Returns:

  • (Object)

    the current value of node



1
2
3
# File 'lib/eggnog/node.rb', line 1

def node
  @node
end

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



1
2
3
# File 'lib/eggnog/node.rb', line 1

def options
  @options
end

Class Method Details

.to_hash(node, options = {}) ⇒ Object



5
6
7
# File 'lib/eggnog/node.rb', line 5

def self.to_hash(node, options = {})
  new(node, options).to_hash
end

Instance Method Details

#to_hash(parent_hash = {}) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/eggnog/node.rb', line 9

def to_hash(parent_hash = {})
  case node
  when Nokogiri::XML::Document
    self.class.to_hash(node.root, options)
  else
    insert_into_parent_hash(parent_hash, collect_nodes)
  end
end