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.



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

#argsObject (readonly)

Returns the value of attribute args.



63
64
65
# File 'lib/chroma/palette_builder.rb', line 63

def args
  @args
end

#nameObject (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