Class: Chroma::PaletteBuilder::PaletteBuilderDsl::ColorCalls

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(name, args) ⇒ ColorCalls

Returns a new instance of ColorCalls


56
57
58
# File 'lib/chroma/palette_builder.rb', line 56

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


66
67
68
# File 'lib/chroma/palette_builder.rb', line 66

def method_missing(name, *args)
  @calls << [name, args]
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args


54
55
56
# File 'lib/chroma/palette_builder.rb', line 54

def args
  @args
end

#nameObject (readonly)

Returns the value of attribute name


54
55
56
# File 'lib/chroma/palette_builder.rb', line 54

def name
  @name
end

Instance Method Details

#evaluate(color) ⇒ Object


60
61
62
63
64
# File 'lib/chroma/palette_builder.rb', line 60

def evaluate(color)
  @calls.reduce(color) do |c, (name, args)|
    c.send(name, *args)
  end
end