Class: BottleRocket::ContentTags::ContentTag
- Inherits:
-
Object
- Object
- BottleRocket::ContentTags::ContentTag
- Defined in:
- lib/bottle_rocket/content_tag.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#tag_type ⇒ Object
readonly
Returns the value of attribute tag_type.
Instance Method Summary collapse
- #html_attributes ⇒ Object
-
#initialize(tag_type, attributes = {}) ⇒ ContentTag
constructor
A new instance of ContentTag.
- #to_s(&block) ⇒ Object
Constructor Details
#initialize(tag_type, attributes = {}) ⇒ ContentTag
Returns a new instance of ContentTag.
7 8 9 10 |
# File 'lib/bottle_rocket/content_tag.rb', line 7 def initialize(tag_type, attributes={}) @tag_type = tag_type @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/bottle_rocket/content_tag.rb', line 5 def attributes @attributes end |
#tag_type ⇒ Object (readonly)
Returns the value of attribute tag_type.
5 6 7 |
# File 'lib/bottle_rocket/content_tag.rb', line 5 def tag_type @tag_type end |
Instance Method Details
#html_attributes ⇒ Object
16 17 18 |
# File 'lib/bottle_rocket/content_tag.rb', line 16 def html_attributes attributes.map {|k, v| "#{k}=\"#{v}\"" }.join(' ') end |
#to_s(&block) ⇒ Object
12 13 14 |
# File 'lib/bottle_rocket/content_tag.rb', line 12 def to_s(&block) "<#{tag_type} #{html_attributes}>" + (block_given? ? yield : '') + "</#{tag_type}>" end |