Class: MetaBuilder::ParameterTypes::ArrayParameter
- Inherits:
-
MetaBuilder::ParameterType
- Object
- MetaBuilder::ParameterType
- MetaBuilder::ParameterTypes::ArrayParameter
- Defined in:
- lib/MetaBuilder/Parameters/lists.rb
Overview
An array of identical elements of type specified by :subtype. Defaults to String
Instance Method Summary collapse
-
#initialize(type) ⇒ ArrayParameter
constructor
A new instance of ArrayParameter.
- #string_to_type_internal(str) ⇒ Object
- #type_name ⇒ Object
- #type_to_string_internal(val) ⇒ Object
Methods inherited from MetaBuilder::ParameterType
#default_value, from_string, get_param_type, get_type, #lookup_const, #option_parser_long_option, #option_parser_option, #option_parser_raw, #qt4_create_input_widget, #qt4_get, #string_to_type, #stt_run_hook, type_name, #type_to_string, #type_to_variant, #variant_to_type
Constructor Details
#initialize(type) ⇒ ArrayParameter
Returns a new instance of ArrayParameter.
104 105 106 107 108 109 110 111 |
# File 'lib/MetaBuilder/Parameters/lists.rb', line 104 def initialize(type) super # We make a copy for our own purposes. subtype = type[:subtype] || {:type => :string} @subtype = ParameterType.get_type(subtype) @separator = /\s*,\s*/ @separator_out = ',' end |
Instance Method Details
#string_to_type_internal(str) ⇒ Object
117 118 119 120 121 122 |
# File 'lib/MetaBuilder/Parameters/lists.rb', line 117 def string_to_type_internal(str) ary = str.split(@separator) return ary.map do |a| @subtype.string_to_type(a) end end |
#type_name ⇒ Object
113 114 115 |
# File 'lib/MetaBuilder/Parameters/lists.rb', line 113 def type_name return 'array' end |
#type_to_string_internal(val) ⇒ Object
124 125 126 127 128 |
# File 'lib/MetaBuilder/Parameters/lists.rb', line 124 def type_to_string_internal(val) return val.map do |a| @subtype.type_to_string(a) end.join(@separator_out) end |