Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/html_attributes/array.rb

Instance Method Summary collapse

Instance Method Details

#to_class_attrObject

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_attrObject

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_attrObject

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