Class: CssColorContrast::CommandInterpreter::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/css_color_contrast/command_interpreter.rb

Direct Known Subclasses

AdjustLightness, AssignVariable, Info, Ratio

Defined Under Namespace

Classes: AdjustLightness, AssignVariable, Info, Ratio

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, env = {}) ⇒ Function

Returns a new instance of Function.



39
40
41
42
43
# File 'lib/css_color_contrast/command_interpreter.rb', line 39

def initialize(name, env = {})
  @name = name
  @env = env
  @params = []
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



37
38
39
# File 'lib/css_color_contrast/command_interpreter.rb', line 37

def name
  @name
end

#paramsObject (readonly)

Returns the value of attribute params.



37
38
39
# File 'lib/css_color_contrast/command_interpreter.rb', line 37

def params
  @params
end

Class Method Details

.create(name, env = {}) ⇒ Object



117
118
119
120
121
# File 'lib/css_color_contrast/command_interpreter.rb', line 117

def self.create(name, env = {})
  return AssignVariable.new(name, env) if name.start_with?('@')

  FUNCTION_TABLE[name].new(name, env)
end

Instance Method Details

#param_valuesObject



49
50
51
# File 'lib/css_color_contrast/command_interpreter.rb', line 49

def param_values
  @params.map(&:evaluate).flatten
end

#push(param) ⇒ Object



45
46
47
# File 'lib/css_color_contrast/command_interpreter.rb', line 45

def push(param)
  @params.push(param)
end