Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/hoshi/monkey_patches.rb
Instance Method Summary collapse
-
#to_html_options(double_quotes = true) ⇒ Object
Makes this hash fit to be put into a tag.
Instance Method Details
#to_html_options(double_quotes = true) ⇒ Object
Makes this hash fit to be put into a tag. { :a => 1, :b => “two”, :c => true }.to_html_options # => ‘a=“one” b=“two” c’
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/hoshi/monkey_patches.rb', line 4 def double_quotes = true qchar = double_quotes ? '"' : "'" map { |k,v| if v == true k.to_s else "#{k}=#{qchar}#{v}#{qchar}" end }.join(' ') end |