Class: DataFormatter::Tag
- Inherits:
-
Object
- Object
- DataFormatter::Tag
- Defined in:
- lib/data_formatter/tag.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#css_class ⇒ Object
readonly
Returns the value of attribute css_class.
-
#sanitizer ⇒ Object
readonly
Returns the value of attribute sanitizer.
-
#surround ⇒ Object
readonly
Returns the value of attribute surround.
-
#tag_name ⇒ Object
readonly
Returns the value of attribute tag_name.
Instance Method Summary collapse
-
#initialize(args) ⇒ Tag
constructor
A new instance of Tag.
- #to_s ⇒ Object
Constructor Details
#initialize(args) ⇒ Tag
Returns a new instance of Tag.
8 9 10 11 12 13 14 |
# File 'lib/data_formatter/tag.rb', line 8 def initialize(args) @sanitizer = args.fetch(:sanitizer, Rack::Utils) @tag_name = args.fetch(:tag_name, "span") @content = args.fetch(:content) @surround = args.fetch(:surround, nil) @css_class = Array(args.fetch(:css_class, "")).compact.join(" ") end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
6 7 8 |
# File 'lib/data_formatter/tag.rb', line 6 def content @content end |
#css_class ⇒ Object (readonly)
Returns the value of attribute css_class.
6 7 8 |
# File 'lib/data_formatter/tag.rb', line 6 def css_class @css_class end |
#sanitizer ⇒ Object (readonly)
Returns the value of attribute sanitizer.
6 7 8 |
# File 'lib/data_formatter/tag.rb', line 6 def sanitizer @sanitizer end |
#surround ⇒ Object (readonly)
Returns the value of attribute surround.
6 7 8 |
# File 'lib/data_formatter/tag.rb', line 6 def surround @surround end |
#tag_name ⇒ Object (readonly)
Returns the value of attribute tag_name.
6 7 8 |
# File 'lib/data_formatter/tag.rb', line 6 def tag_name @tag_name end |
Instance Method Details
#to_s ⇒ Object
16 17 18 |
# File 'lib/data_formatter/tag.rb', line 16 def to_s [open_tag, safe_content, close_tag].join end |