Class: Chroma::PaletteBuilder::PaletteBuilderDsl::ColorCalls
- Inherits:
-
Object
- Object
- Chroma::PaletteBuilder::PaletteBuilderDsl::ColorCalls
- Defined in:
- lib/chroma/palette_builder.rb
Overview
Internal class to represent color modification calls in the palette builder DSL definition syntax.
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #evaluate(color) ⇒ Object
-
#initialize(name, args) ⇒ ColorCalls
constructor
A new instance of ColorCalls.
- #method_missing(name, *args) ⇒ Object
Constructor Details
#initialize(name, args) ⇒ ColorCalls
Returns a new instance of ColorCalls.
65 66 67 |
# File 'lib/chroma/palette_builder.rb', line 65 def initialize(name, args) @calls = [[name, args]] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
75 76 77 |
# File 'lib/chroma/palette_builder.rb', line 75 def method_missing(name, *args) @calls << [name, args] end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
63 64 65 |
# File 'lib/chroma/palette_builder.rb', line 63 def args @args end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
63 64 65 |
# File 'lib/chroma/palette_builder.rb', line 63 def name @name end |
Instance Method Details
#evaluate(color) ⇒ Object
69 70 71 72 73 |
# File 'lib/chroma/palette_builder.rb', line 69 def evaluate(color) @calls.reduce(color) do |c, (name, args)| c.send(name, *args) end end |