Class: ShellOpts::Grammar::ArgumentType
- Inherits:
-
Object
- Object
- ShellOpts::Grammar::ArgumentType
- Defined in:
- lib/shellopts/argument_type.rb
Direct Known Subclasses
EnumArgument, FileArgument, FloatArgument, IntegerArgument, StringType
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Error message if match? returned false.
Instance Method Summary collapse
-
#convert(value) ⇒ Object
Convert value to Ruby type.
-
#match?(name, literal) ⇒ Boolean
Return truish if value literal (String) match the type.
-
#name ⇒ Object
Name of type.
-
#to_s ⇒ Object
String representation.
-
#value?(value) ⇒ Boolean
Return true if .value is an “instance” of self.
Instance Attribute Details
#message ⇒ Object (readonly)
Error message if match? returned false. Note that this method is not safe for concurrent processing
15 16 17 |
# File 'lib/shellopts/argument_type.rb', line 15 def @message end |
Instance Method Details
#convert(value) ⇒ Object
Convert value to Ruby type. This method can also be used to translate special keywords
23 |
# File 'lib/shellopts/argument_type.rb', line 23 def convert(value) value end |
#match?(name, literal) ⇒ Boolean
Return truish if value literal (String) match the type. Returns false and set #message if the value doesn’t match. <name> is used to construct the error message and is the name/alias the user specified on the command line
11 |
# File 'lib/shellopts/argument_type.rb', line 11 def match?(name, literal) true end |
#name ⇒ Object
Name of type
5 |
# File 'lib/shellopts/argument_type.rb', line 5 def name() self.class.to_s.sub(/.*::/, "").sub(/Argument/, "") end |
#to_s ⇒ Object
String representation. Equal to #name
26 |
# File 'lib/shellopts/argument_type.rb', line 26 def to_s() name end |
#value?(value) ⇒ Boolean
Return true if .value is an “instance” of self. Ie. an Integer object if type is an IntegerArgument
19 |
# File 'lib/shellopts/argument_type.rb', line 19 def value?(value) true end |