Class: Bricolage::Parameters::DirectValueHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/bricolage/parameters.rb

Overview

Handles *.job file values. Declarations + values -> IntermediateValues

Instance Method Summary collapse

Constructor Details

#initialize(decls) ⇒ DirectValueHandler

Returns a new instance of DirectValueHandler.



83
84
85
# File 'lib/bricolage/parameters.rb', line 83

def initialize(decls)
  @decls = decls   # Declarations
end

Instance Method Details

#parse(values) ⇒ Object

values

=> a



88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/bricolage/parameters.rb', line 88

def parse(values)
  parsed_values = {}
  vars = Variables.new
  values.each do |name, value|
    if decl = @decls[name]
      val = decl.parse_value(value)
      # nil is equal to "no option given" semantically
      parsed_values[name] = val unless val.nil?
    else
      vars.add Variable.new(name, value)
    end
  end
  IntermediateValues.new(@decls, parsed_values, vars)
end