Class: XMLResume2x::REXMLBuilder
- Inherits:
-
Object
- Object
- XMLResume2x::REXMLBuilder
show all
- Defined in:
- lib/xmlresume2x/xmlmarkup.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of REXMLBuilder.
69
70
71
|
# File 'lib/xmlresume2x/xmlmarkup.rb', line 69
def initialize( element )
@element = element
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) {|XMLResume2x::REXMLBuilder.new( new_elem )| ... } ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/xmlresume2x/xmlmarkup.rb', line 73
def method_missing( name, *args, &block )
attrs = {}
content = nil
args.each do |a|
if a.instance_of? Hash
attrs.merge!( a )
else
content ||= []
content << a
end
end
new_elem = @element.add_element( name.to_s, attrs )
new_elem.add( content ) unless content.nil?
yield XMLResume2x::REXMLBuilder.new( new_elem ) if block_given?
self
end
|
Instance Method Details
#add!(object, *others) ⇒ Object
95
96
97
98
|
# File 'lib/xmlresume2x/xmlmarkup.rb', line 95
def add!( object, *others )
@element.add( object, *others )
self
end
|
#element! ⇒ Object
100
101
102
|
# File 'lib/xmlresume2x/xmlmarkup.rb', line 100
def element!
@element
end
|
#text!(str) ⇒ Object
90
91
92
93
|
# File 'lib/xmlresume2x/xmlmarkup.rb', line 90
def text!( str )
@element.add_text( str )
self
end
|