Class: ShellOpts::Grammar::IntegerArgument

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

Instance Attribute Summary

Attributes inherited from ArgumentType

#message

Instance Method Summary collapse

Methods inherited from ArgumentType

#name, #to_s

Instance Method Details

#convert(value) ⇒ Object



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

def convert(value) value.to_i end

#match?(name, literal) ⇒ Boolean

Returns:



39
40
41
42
# File 'lib/shellopts/argument_type.rb', line 39

def match?(name, literal) 
  literal =~ /^-?\d+$/ or 
      set_message "Illegal integer value in #{name}: #{literal}" 
end

#value?(value) ⇒ Boolean

Returns:



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

def value?(value) value.is_a?(Integer) end