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.
169 170 171 172 173 |
# File 'lib/sassafras.rb', line 169 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
187 188 189 190 |
# File 'lib/sassafras.rb', line 187 def method_missing(method, *args) return @colors[method.to_s] if @colors[method.to_s] super end |
Instance Method Details
#colors ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/sassafras.rb', line 175 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 |