Class: CTioga2::MetaBuilder::Types::SetParameter
- Inherits:
-
ArrayParameter
- Object
- CTioga2::MetaBuilder::Type
- ArrayParameter
- CTioga2::MetaBuilder::Types::SetParameter
- Defined in:
- lib/ctioga2/metabuilder/types/lists.rb
Overview
A Type used for sets for Graphics::Styles::CircularArray objects.
todo write a gradient stuff !!!
Instance Attribute Summary
Attributes inherited from CTioga2::MetaBuilder::Type
#passthrough, #re_shortcuts, #shortcuts, #type
Instance Method Summary collapse
-
#initialize(type) ⇒ SetParameter
constructor
A new instance of SetParameter.
- #string_to_type_internal(str) ⇒ Object
- #type_name ⇒ Object
Methods inherited from ArrayParameter
Methods inherited from CTioga2::MetaBuilder::Type
#boolean?, #default_value, from_string, get_param_type, get_type, #option_parser_long_option, #option_parser_option, #string_to_type, type_name, #type_to_string
Constructor Details
#initialize(type) ⇒ SetParameter
Returns a new instance of SetParameter.
181 182 183 184 185 |
# File 'lib/ctioga2/metabuilder/types/lists.rb', line 181 def initialize(type) super @separator = /\s*\|\s*/ @separator_out = '|' end |
Instance Method Details
#string_to_type_internal(str) ⇒ Object
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/ctioga2/metabuilder/types/lists.rb', line 191 def string_to_type_internal(str) multiply = nil if str =~ /(.*)\*\s*(\d+)\s*$/ multiply = $2.to_i str = $1 end if str =~ /^\s*gradient:(.+)--(.+),(\d+)\s*$/ s,e,nb = $1, $2, $3.to_i s,e = @subtype.string_to_type(s),@subtype.string_to_type(e) fact = if nb > 1 1.0/(nb - 1) # The famous off-by one... else warn { "Incorrect gradient number: #{nb}" } 1.0 end array = [] nb.times do |i| array << Utils::mix_objects(e,s, i * fact) end else array = super end if multiply # Seems that I've finally managed to understand what zip # is useful for ! array = array.zip(*([array]*(multiply-1))).flatten(1) end return array end |
#type_name ⇒ Object
187 188 189 |
# File 'lib/ctioga2/metabuilder/types/lists.rb', line 187 def type_name return 'set' end |