class CTioga2::MetaBuilder::Types::ArrayParameter

An array of identical elements of type specified by :subtype. Defaults to String

Public Class Methods

new(type) click to toggle source
Calls superclass method CTioga2::MetaBuilder::Type::new
# File lib/ctioga2/metabuilder/types/lists.rb, line 144
def initialize(type)
  super
  # We make a copy for our own purposes.
  subtype = type[:subtype] || {:type => :string}
  @subtype = Type.get_type(subtype)
  @separator = type[:separator] || /\s*,\s*/
  @alternative_separator = type[:alternative_separator] || nil
  @separator_out = type[:separator_out] || ','
end

Public Instance Methods

string_to_type_internal(str) click to toggle source
# File lib/ctioga2/metabuilder/types/lists.rb, line 158
def string_to_type_internal(str)
  if @alternative_separator && str =~ @alternative_separator
    ary = str.split(@alternative_separator)
  else
    ary = str.split(@separator)
  end
  return ary.map do |a|
    @subtype.string_to_type(a)
  end
end
type_name() click to toggle source
# File lib/ctioga2/metabuilder/types/lists.rb, line 154
def type_name
  return 'array'
end
type_to_string_internal(val) click to toggle source
# File lib/ctioga2/metabuilder/types/lists.rb, line 169
def type_to_string_internal(val)
  return val.map do |a|
    @subtype.type_to_string(a)
    # Won't alway work !
  end.join(@separator_out)
end