Class: It::Tag
- Inherits:
-
Object
- Object
- It::Tag
- Includes:
- ActionView::Helpers::TagHelper
- Defined in:
- lib/it/tag.rb
Overview
A generic class for html tags.
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#tag_name ⇒ Object
readonly
Returns the value of attribute tag_name.
Instance Method Summary collapse
-
#initialize(tag_name, options = {}) ⇒ Tag
constructor
See It.tag for details.
-
#process(content = nil) ⇒ Object
Will be called from inside the helper to return the tag with the given content.
Constructor Details
#initialize(tag_name, options = {}) ⇒ Tag
See It.tag for details. You can do everything there and save 6 characters.
9 10 11 12 13 14 15 |
# File 'lib/it/tag.rb', line 9 def initialize(tag_name, = {}) raise TypeError, 'tag_name must be a String or Symbol' unless [String, Symbol].include?(tag_name.class) raise TypeError, 'options must be a Hash' unless .is_a?(Hash) @tag_name = tag_name.to_sym @options = .symbolize_keys end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/it/tag.rb', line 6 def @options end |
#tag_name ⇒ Object (readonly)
Returns the value of attribute tag_name.
6 7 8 |
# File 'lib/it/tag.rb', line 6 def tag_name @tag_name end |
Instance Method Details
#process(content = nil) ⇒ Object
Will be called from inside the helper to return the tag with the given content.
18 19 20 21 22 23 24 |
# File 'lib/it/tag.rb', line 18 def process(content = nil) # :nodoc: if content content_tag(@tag_name, content, @options) else tag(@tag_name, @options) end end |