class Como::ArgsParseState
Command argument parsing state.
Public Class Methods
new( list )
click to toggle source
Create parse state.
@param list [Array<String>] List of Command Line Arguments
(default: ARGV).
# File lib/como.rb, line 2160 def initialize( list ) set( list ) @idx = 0 end
Public Instance Methods
done?()
click to toggle source
Parser at argument list end?
# File lib/como.rb, line 2196 def done? @idx >= @list.length end
get( idx = @idx )
click to toggle source
Get current argument.
# File lib/como.rb, line 2181 def get( idx = @idx ) @args[ idx ] end
isOpt( str = get )
click to toggle source
Test whether str is an option.
# File lib/como.rb, line 2201 def isOpt( str = get ) str[0..0] == "-" end
isOptTerm( str = get )
click to toggle source
Test whether str is an option list terminator.
# File lib/como.rb, line 2206 def isOptTerm( str = get ) str == "--" end
last( idx = @idx )
click to toggle source
Get last argument.
# File lib/como.rb, line 2186 def last( idx = @idx ) idx == ( @args.length-1 ) end
next()
click to toggle source
Step to next argument.
# File lib/como.rb, line 2171 def next @idx += 1 end
prev()
click to toggle source
Step to previous argument.
# File lib/como.rb, line 2176 def prev @idx -= 1 end
rest( idx = @idx )
click to toggle source
Get rest of the arguments.
# File lib/como.rb, line 2191 def rest( idx = @idx ) @args[ idx..-1 ] end
set( list )
click to toggle source
Set list of arguments.
# File lib/como.rb, line 2166 def set( list ) @args = list end
toValue( str = get )
click to toggle source
Format value string if escaped.
# File lib/como.rb, line 2211 def toValue( str = get ) if str[0..0] == "\\" str[1..-1] else str end end