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
348
349
350
# File 'lib/htmlcom.rb', line 336

def initialize(obj)

  puts 'about to build object: ' + obj.inspect
  @doc = build(obj)
  puts '@doc.xml : ' + @doc.xml.inspect

  if @id then
    puts '@tag, @html -> ' + [@tag, @htmltag].inspect
    elem = @doc.root.element(@tag + '/' + @htmltag)
    puts 'elem2: ' +elem.inspect
    elem.attributes[:name] = @id
    elem.attributes[:id] = @id
  end

end

Instance Method Details

#html_elementObject



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

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

#to_docObject



356
357
358
# File 'lib/htmlcom.rb', line 356

def to_doc()
  @doc
end

#to_htmlObject



360
361
362
# File 'lib/htmlcom.rb', line 360

def to_html()
  html_element.xml pretty: true
end