Class: Burlap::Node
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Node
constructor
name is the element name to go in the <> and value is a string to go in the node.
-
#to_burlap ⇒ Object
Packs this object into nokogiri nodes and returns the XML as a string.
Constructor Details
#initialize(params = {}) ⇒ Node
name is the element name to go in the <> and value is a string to go in the node
7 8 9 10 11 12 |
# File 'lib/burlap/node.rb', line 7 def initialize params={} params.each do |k,v| meffod = :"#{k}=" send(meffod, v) #if respond_to?(meffod) end end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/burlap/node.rb', line 3 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
3 4 5 |
# File 'lib/burlap/node.rb', line 3 def value @value end |
Instance Method Details
#to_burlap ⇒ Object
Packs this object into nokogiri nodes and returns the XML as a string
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/burlap/node.rb', line 15 def to_burlap doc = Nokogiri::XML::Document.new root = Nokogiri::XML::Node.new(self.name, doc) if self.value.to_s == "" root.children = self.value.to_s else root << self.value.to_s end convert_hex_entities_to_decimal root.to_xml() end |