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



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

def convert(value) value.to_i end

#match?(name, literal) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#value?(value) ⇒ Boolean

Returns:

  • (Boolean)


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

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