class CTioga2::MetaBuilder::Types::ListParameter
A list of symbols. A hash :list must be provided that states the correspondance between the legal symbols that can be accepted by this parameter and their “english” name. This parameter can typically be used to prompt the user for different choices.
Public Class Methods
new(type)
click to toggle source
Calls superclass method
CTioga2::MetaBuilder::Type::new
# File lib/ctioga2/metabuilder/types/lists.rb, line 82 def initialize(type) super raise "type must have a :list key" unless type.has_key?(:list) # We make a copy for our own purposes. @hash = type[:list].dup end
Public Instance Methods
string_to_type_internal(str)
click to toggle source
# File lib/ctioga2/metabuilder/types/lists.rb, line 93 def string_to_type_internal(str) if @hash.has_key?(str.to_sym) return str.to_sym else raise IncorrectInput, "Invalid input: '#{str}' should be one of " + @hash.keys.map {|s| s.to_s}.join(',') end end
type_name()
click to toggle source
# File lib/ctioga2/metabuilder/types/lists.rb, line 89 def type_name return 'list' end
type_to_string_internal(val)
click to toggle source
# File lib/ctioga2/metabuilder/types/lists.rb, line 102 def type_to_string_internal(val) return val.to_s end