Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/html_attributes/array.rb
Instance Method Summary collapse
-
#to_class_attr ⇒ Object
Returns a string representing the value of a HTML class attribute or nil (if empty).
-
#to_rel_attr ⇒ Object
Returns a string representing the value of a HTML rel attribute or nil (if empty).
-
#to_style_attr ⇒ Object
Returns a string representing the value of a HTML style attribute or nil (if empty).
Instance Method Details
#to_class_attr ⇒ Object
Returns a string representing the value of a HTML class attribute or nil (if empty).
Examples
["post", "comment", "spam"].to_class_attr
# => "post comment spam"
[].to_class_attr
# => nil
13 14 15 |
# File 'lib/html_attributes/array.rb', line 13 def to_class_attr empty? ? nil : join(' ') end |
#to_rel_attr ⇒ Object
Returns a string representing the value of a HTML rel attribute or nil (if empty).
Examples
["nofollow", "me"].to_rel_attr
# => "nofollow me"
[].to_class_attr
# => nil
27 28 29 |
# File 'lib/html_attributes/array.rb', line 27 def to_rel_attr empty? ? nil : join(' ') end |
#to_style_attr ⇒ Object
Returns a string representing the value of a HTML style attribute or nil (if empty).
Examples
["padding-top: 8px", "padding-right: 15px", "font-size: 12pt"].to_style_attr
# => "padding-top: 8px; padding-right: 15px; font-size: 12pt;"
[].to_style_attr
# => nil
41 42 43 |
# File 'lib/html_attributes/array.rb', line 41 def to_style_attr empty? ? nil : join('; ').concat(';') end |