public
Created

Gist #8 For "Functional Programming Techniques With Ruby: Part I"

  • Download Gist
gist_8_functional_ruby.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
class CssBlock
 
# ...
 
def set(key, value = nil)
new_properties = if key.is_a?(Hash)
key
elsif !value.nil?
{
key => value
}
else
raise "Either provide a Hash of values, or a key and value."
end
 
self.class.new(self.selector, self.properties.merge(new_properties))
end
 
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.