Class: ShellOpts::Grammar::ArgumentType

Inherits:
Object
  • Object
show all
Defined in:
lib/shellopts/argument_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#messageObject (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
  @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

Returns:

  • (Boolean)


11
# File 'lib/shellopts/argument_type.rb', line 11

def match?(name, literal) true end

#nameObject

Name of type



5
# File 'lib/shellopts/argument_type.rb', line 5

def name() self.class.to_s.sub(/.*::/, "").sub(/Argument/, "") end

#to_sObject

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

Returns:

  • (Boolean)


19
# File 'lib/shellopts/argument_type.rb', line 19

def value?(value) true end