Class: MetaTags::Tag
- Defined in:
- lib/meta_tags/tag.rb,
sig/lib/meta_tags/tag.rbs
Overview
Represents an HTML meta tag with no content (
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attributes ⇒ Hash[String | Symbol, untyped]
readonly
Returns the value of attribute attributes.
-
#name ⇒ String
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, attributes = {}) ⇒ Tag
constructor
Initializes a new instance of Tag class.
-
#render(view) ⇒ String
Renders the tag in a Rails view.
-
#serialize_iso8601_attributes(attributes) ⇒ Hash
Serializes attribute values that support ISO 8601 formatting.
Constructor Details
#initialize(name, attributes = {}) ⇒ Tag
Initializes a new instance of Tag class.
12 13 14 15 |
# File 'lib/meta_tags/tag.rb', line 12 def initialize(name, attributes = {}) @name = name.to_s @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Hash[String | Symbol, untyped] (readonly)
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/meta_tags/tag.rb', line 6 def attributes @attributes end |
#name ⇒ String (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/meta_tags/tag.rb', line 6 def name @name end |
Instance Method Details
#render(view) ⇒ String
Renders the tag in a Rails view.
21 22 23 |
# File 'lib/meta_tags/tag.rb', line 21 def render(view) view.tag(name, serialize_iso8601_attributes(attributes), MetaTags.config.) end |
#serialize_iso8601_attributes(attributes) ⇒ Hash
Serializes attribute values that support ISO 8601 formatting.
31 32 33 34 35 |
# File 'lib/meta_tags/tag.rb', line 31 def serialize_iso8601_attributes(attributes) attributes.each do |key, value| attributes[key] = value.iso8601 if value.respond_to?(:iso8601) end end |