Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/hoshi/monkey_patches.rb

Instance Method Summary collapse

Instance Method Details

#to_html_options(double_quotes = true) ⇒ Object

Makes this hash fit to be put into a tag. { :a => 1, :b => “two” }.to_html_options # => ‘a=“one” b=“two”’



4
5
6
7
# File 'lib/hoshi/monkey_patches.rb', line 4

def to_html_options double_quotes = true
	qchar = double_quotes ? '"' : "'"
	map { |k,v| "#{k}=#{qchar}#{v}#{qchar}" }.join(' ')
end