Class: Calligraphy::XML::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/calligraphy/xml/node.rb

Overview

Simple XML node, used to store resource properties in Resource methods and later to create XML response bodies.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node = nil) ⇒ Node

:nodoc:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/calligraphy/xml/node.rb', line 11

def initialize(node = nil)
  return if node.nil?

  @name = node.name
  @text = node.text unless node.text.empty?

  if node.namespace
    @namespace = Calligraphy::XML::Namespace.new node.namespace
  end

  return unless node_has_children node

  @children = []
  node.children.each { |x| @children.push Calligraphy::XML::Node.new x }
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



8
9
10
# File 'lib/calligraphy/xml/node.rb', line 8

def children
  @children
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/calligraphy/xml/node.rb', line 8

def name
  @name
end

#namespaceObject

Returns the value of attribute namespace.



8
9
10
# File 'lib/calligraphy/xml/node.rb', line 8

def namespace
  @namespace
end

#textObject

Returns the value of attribute text.



8
9
10
# File 'lib/calligraphy/xml/node.rb', line 8

def text
  @text
end