Class: Ox::Builder::Factory
- Inherits:
-
Object
- Object
- Ox::Builder::Factory
- Includes:
- DSL
- Defined in:
- lib/ox/builder/factory.rb
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #add_attributes(attributes) ⇒ Object
-
#initialize(node) ⇒ Factory
constructor
A new instance of Factory.
- #inspect ⇒ Object
- #to_s(options = {}) ⇒ Object (also: #to_xml)
Methods included from DSL
#cdata!, #comment!, #doctype!, #instruct!, #tag!
Constructor Details
#initialize(node) ⇒ Factory
Returns a new instance of Factory.
8 9 10 |
# File 'lib/ox/builder/factory.rb', line 8 def initialize(node) @node = node end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (protected)
31 32 33 34 |
# File 'lib/ox/builder/factory.rb', line 31 def method_missing(name, *args, &block) name = name[0...-1] if name.to_s.end_with?('!') tag!(name, *args, &block) end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
6 7 8 |
# File 'lib/ox/builder/factory.rb', line 6 def node @node end |
Instance Method Details
#add_attributes(attributes) ⇒ Object
23 24 25 26 27 |
# File 'lib/ox/builder/factory.rb', line 23 def add_attributes(attributes) attributes.each do |key, val| node[key] = val end end |
#inspect ⇒ Object
19 20 21 |
# File 'lib/ox/builder/factory.rb', line 19 def inspect "#<#{self.class.name}:0x#{"%x" % object_id} node=#{node}>" end |
#to_s(options = {}) ⇒ Object Also known as: to_xml
12 13 14 15 16 |
# File 'lib/ox/builder/factory.rb', line 12 def to_s( = {}) encoding = .fetch(:encoding, 'UTF-8') indent = .fetch(:indent, 2) Ox.dump(node, encoding: encoding, indent: indent) end |