Class: Sassafras::ColorSet
- Inherits:
-
Object
- Object
- Sassafras::ColorSet
- Defined in:
- lib/sassafras.rb
Instance Method Summary collapse
- #colors ⇒ Object
-
#initialize(base_rgb, prefix = nil) ⇒ ColorSet
constructor
A new instance of ColorSet.
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize(base_rgb, prefix = nil) ⇒ ColorSet
Returns a new instance of ColorSet.
129 130 131 132 133 |
# File 'lib/sassafras.rb', line 129 def initialize(base_rgb, prefix=nil) @rgb = base_rgb @prefix = prefix @colors = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
147 148 149 150 |
# File 'lib/sassafras.rb', line 147 def method_missing(method, *args) return @colors[method.to_s] if @colors[method.to_s] super end |
Instance Method Details
#colors ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/sassafras.rb', line 135 def colors returning Hash.new do |hash| @colors.each do |name, hex| if @prefix hash["#{@prefix}_#{name}"] = hex else hash[name] = hex end end end end |