Class: Bricolage::StringListParam
- Inherits:
-
Param
- Object
- Param
- Bricolage::StringListParam
show all
- Defined in:
- lib/bricolage/parameters.rb
Instance Attribute Summary
Attributes inherited from Param
#arg_spec, #description, #name
Instance Method Summary
collapse
Methods inherited from Param
#have_arg?, #inspect, #option_name, #optional?, #publish?, #required?
Constructor Details
#initialize(name, arg_spec, description, optional: false, publish: false, allow_string: false) ⇒ StringListParam
Returns a new instance of StringListParam.
607
608
609
610
|
# File 'lib/bricolage/parameters.rb', line 607
def initialize(name, arg_spec, description, optional: false, publish: false, allow_string: false)
super name, arg_spec, description, optional: optional, publish: publish
@allow_string = allow_string
end
|
Instance Method Details
#default_value(ctx, vars) ⇒ Object
625
626
627
|
# File 'lib/bricolage/parameters.rb', line 625
def default_value(ctx, vars)
[]
end
|
#materialize(vals, ctx, vars) ⇒ Object
629
630
631
|
# File 'lib/bricolage/parameters.rb', line 629
def materialize(vals, ctx, vars)
vals.map {|val| expand(val, vars) }
end
|
#parse_option_value(value, list) ⇒ Object
612
613
614
615
|
# File 'lib/bricolage/parameters.rb', line 612
def parse_option_value(value, list)
(list ||= []).push value
list end
|
#parse_value(vals) ⇒ Object
617
618
619
620
621
622
623
|
# File 'lib/bricolage/parameters.rb', line 617
def parse_value(vals)
unless vals.kind_of?(Array)
raise ParameterError, "bad type for parameter #{name}: #{vals.class}" unless @allow_string
vals = [vals]
end
vals.empty? ? nil : vals
end
|
#variables(strs) ⇒ Object
633
634
635
|
# File 'lib/bricolage/parameters.rb', line 633
def variables(strs)
wrap_variable_value(strs.join(' '))
end
|