Class: HtmlCom::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/htmlcom.rb

Direct Known Subclasses

Form, InputElement

Instance Method Summary collapse

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_elementObject



349
350
351
# File 'lib/htmlcom.rb', line 349

def html_element()
  @doc.root.element(@tag + '/' + @htmltag)
end

#to_docObject



353
354
355
# File 'lib/htmlcom.rb', line 353

def to_doc()
  @doc
end