TypesModule
- Namespace
Types registered with Ame for parsing command-line arguments into Ruby values. By default, Ruby classes TrueClass, FalseClass, Float, Integer, String, and Symbol are registered, as well as an Enumeration type for limiting a Symbol to one of a fixed set.
Children
- Enumeration
-
Enumeration type for limiting a Symbol argument to one in a fixed set.
Class Methods
register(type#parse, #default, *classes::Class*)self#⚙
Registers type for parsing command-line arguments for Ruby values whose class is any of classes. The type should respond to #parse(String), which should convert its String argument into a Ruby value, and may optionally respond to #default, which should return the default value of the type, if any.
- Example: Registering a New Type
require 'pathname' module My::Pathname Ame::Types.register self, Pathname def parse(argument) Pathname(argument) end end
- Example: Using a New Type as a Type
class Rm < Ame::Root … splus 'FILE', My::Pathname, 'File to remove' def rm(pathnames) pathnames.each do |e| e.rmtree end end end
- Example: Using a New Types as a Default
class My < Ame::Root optional 'CONFIG', Pathname('/etc/my/config'), 'Configuration file to use'