Class: Nokogiri::XML::Builder::NodeBuilder
- Inherits:
-
Object
- Object
- Nokogiri::XML::Builder::NodeBuilder
- Defined in:
- lib/nokogiri/xml/builder.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(node, doc_builder) ⇒ NodeBuilder
constructor
A new instance of NodeBuilder.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(node, doc_builder) ⇒ NodeBuilder
Returns a new instance of NodeBuilder.
53 54 55 56 |
# File 'lib/nokogiri/xml/builder.rb', line 53 def initialize(node, doc_builder) @node = node @doc_builder = doc_builder end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/nokogiri/xml/builder.rb', line 58 def method_missing(method, *args, &block) case method.to_s when /^(.*)!$/ @node['id'] = $1 @node.content = args.first if args.first when /^(.*)=/ @node[$1] = args.first else @node['class'] = ((@node['class'] || '').split(/\s/) + [method.to_s]).join(' ') @node.content = args.first if args.first end if block_given? @doc_builder.parent = @node return @doc_builder.instance_eval(&block) end self end |