Class: Navigator::Tag
- Inherits:
-
Object
- Object
- Navigator::Tag
- Defined in:
- lib/navigator/tag.rb
Overview
Renders a HTML tag.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, content = nil, attributes: {}, activator: Navigator::TagActivator.new) ⇒ Tag
constructor
A new instance of Tag.
- #prefix ⇒ Object
- #render ⇒ Object
- #suffix ⇒ Object
Constructor Details
#initialize(name, content = nil, attributes: {}, activator: Navigator::TagActivator.new) ⇒ Tag
Returns a new instance of Tag.
6 7 8 9 10 11 |
# File 'lib/navigator/tag.rb', line 6 def initialize name, content = nil, attributes: {}, activator: Navigator::TagActivator.new @name = name @content = content @attributes = attributes.with_indifferent_access @activator = activator end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/navigator/tag.rb', line 4 def content @content end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/navigator/tag.rb', line 4 def name @name end |
Instance Method Details
#prefix ⇒ Object
13 14 15 |
# File 'lib/navigator/tag.rb', line 13 def prefix ["<#{name}", format_attributes, '>'].compact * '' end |
#render ⇒ Object
21 22 23 |
# File 'lib/navigator/tag.rb', line 21 def render [prefix, content, suffix].compact * '' end |
#suffix ⇒ Object
17 18 19 |
# File 'lib/navigator/tag.rb', line 17 def suffix "</#{name}>" end |