Class: SimpleHtml::Tag
- Inherits:
-
Object
- Object
- SimpleHtml::Tag
- Defined in:
- lib/simple_html.rb
Instance Method Summary collapse
-
#initialize(name, content, attributes = {}) ⇒ Tag
constructor
A new instance of Tag.
- #to_html ⇒ Object
Constructor Details
#initialize(name, content, attributes = {}) ⇒ Tag
Returns a new instance of Tag.
5 6 7 8 9 |
# File 'lib/simple_html.rb', line 5 def initialize(name, content, attributes = {}) @name = name @content = content @attributes = attributes end |
Instance Method Details
#to_html ⇒ Object
11 12 13 14 15 16 |
# File 'lib/simple_html.rb', line 11 def to_html attributes = @attributes.sort_by(&:first). map { |key, value| " #{key}=\"#{value}\"" }. join "<#{@name}#{attributes}>#{@content}</#{@name}>" end |