Class: HtmlCom::Element
- Inherits:
-
Object
- Object
- HtmlCom::Element
- Defined in:
- lib/htmlcom.rb
Direct Known Subclasses
Instance Method Summary collapse
- #build(rawobj) ⇒ Object
- #html_element ⇒ Object
-
#initialize(obj) ⇒ Element
constructor
A new instance of Element.
- #to_doc ⇒ Object
Constructor Details
#initialize(obj) ⇒ Element
Returns a new instance of Element.
336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/htmlcom.rb', line 336 def initialize(obj) @doc = build(obj) puts '@doc.xml : ' + @doc.xml.inspect if @id then elem = @doc.root.element(@tag + '/' + @htmltag) puts 'elem: ' +elem.inspect elem.attributes[:name] = @id elem.attributes[:id] = @id end end |
Instance Method Details
#build(rawobj) ⇒ Object
357 358 359 360 |
# File 'lib/htmlcom.rb', line 357 def build(rawobj) obj = rawobj.is_a?(Hash) ? RexleBuilder.new(rawobj).to_a : rawobj Rexle.new(obj) end |
#html_element ⇒ Object
349 350 351 |
# File 'lib/htmlcom.rb', line 349 def html_element() @doc.root.element(@tag + '/' + @htmltag) end |
#to_doc ⇒ Object
353 354 355 |
# File 'lib/htmlcom.rb', line 353 def to_doc() @doc end |