Class: Wizport::Html::Element
- Inherits:
-
Object
- Object
- Wizport::Html::Element
- Defined in:
- lib/wizport/document/html/element.rb
Instance Method Summary collapse
-
#initialize(html) ⇒ Element
constructor
A new instance of Element.
-
#tag(name, *args) ⇒ Object
text = nil, options = {}).
Constructor Details
#initialize(html) ⇒ Element
Returns a new instance of Element.
9 10 11 |
# File 'lib/wizport/document/html/element.rb', line 9 def initialize(html) @html = html end |
Instance Method Details
#tag(name, *args) ⇒ Object
text = nil, options = {})
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/wizport/document/html/element.rb', line 13 def tag(name, *args) #text = nil, options = {}) text = nil = {} case args.size when 1 if args.first.is_a?(Hash) = args.first else text = args.first end when 2 text = args.first = args.last end @html.write '<' @html.write name .each do |k, v| @html.write " #{k}='#{v}'" end @html.write '>' @html.write text if text yield if block_given? @html.write '</' @html.write name @html.write '>' end |