Class: BottleRocket::ContentTags::ContentTag

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/bottle_rocket/content_tag.rb', line 5

def attributes
  @attributes
end

#tag_typeObject (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_attributesObject



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