Class: CssColorContrast::CommandInterpreter::Value

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, env, value = nil) ⇒ Value

Returns a new instance of Value.



23
24
25
26
27
# File 'lib/css_color_contrast/command_interpreter.rb', line 23

def initialize(source, env, value = nil)
  @source = source
  @env = env
  @value = value
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



17
18
19
# File 'lib/css_color_contrast/command_interpreter.rb', line 17

def source
  @source
end

Class Method Details

.assign(source, env, value = nil) ⇒ Object



19
20
21
# File 'lib/css_color_contrast/command_interpreter.rb', line 19

def self.assign(source, env, value = nil)
  new(source, env, value)
end

Instance Method Details

#evaluateObject



29
30
31
32
33
# File 'lib/css_color_contrast/command_interpreter.rb', line 29

def evaluate
  return @env[@source] if @source.start_with?('@')

  @value || @source
end