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 |
# File 'lib/it/tag.rb', line 9 def initialize(tag_name, = {}) raise TypeError, "tag_name must be specified as a String or Symbol" unless tag_name.is_a?(String) || tag_name.is_a?(Symbol) raise TypeError, "options must be specified as 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.
17 18 19 20 21 22 23 |
# File 'lib/it/tag.rb', line 17 def process(content = nil) # :nodoc: if content.nil? tag(@tag_name, @options) else content_tag(@tag_name, content, @options) end end |