Module: CommandMapper::Types

Included in:
Command
Defined in:
lib/command_mapper/types/dec.rb,
lib/command_mapper/types/hex.rb,
lib/command_mapper/types/map.rb,
lib/command_mapper/types/num.rb,
lib/command_mapper/types/str.rb,
lib/command_mapper/types/enum.rb,
lib/command_mapper/types/list.rb,
lib/command_mapper/types/type.rb,
lib/command_mapper/types/input_dir.rb,
lib/command_mapper/types/key_value.rb,
lib/command_mapper/types/input_file.rb,
lib/command_mapper/types/input_path.rb,
lib/command_mapper/types/key_value_list.rb

Defined Under Namespace

Classes: Dec, Enum, Hex, InputDir, InputFile, InputPath, KeyValue, KeyValueList, List, Map, Num, Str, Type

Class Method Summary collapse

Class Method Details

.Type(value) ⇒ Type, Str

Converts a value into a Type object.

Parameters:

  • value (Type, Hash, nil)

    The type value or Hash of keyword arguments.

Returns:

  • (Type, Str)

    The type object or a new Str type object if a Hash of keyword arguments is given.

Raises:

  • (ArgumentError)

    The given type value was not a Type, Hash, or nil,



103
104
105
106
107
108
109
110
111
# File 'lib/command_mapper/types/type.rb', line 103

def self.Type(value)
  case value
  when Type      then value
  when Hash      then Str.new(**value)
  when nil       then nil
  else
    raise(ArgumentError,"value must be a #{Type}, Hash, or nil: #{value.inspect}")
  end
end