class Getopt::Declare::Punctuator
Class used to handle punctuations (., -, etc.)
Public Class Methods
new(text, nows)
click to toggle source
Constructor
# File lib/Getopt/Declare.rb, line 409 def initialize(text, nows) @text = text @nows = nows end
Public Instance Methods
cachecode(ownerflag, itemcount)
click to toggle source
Return string with code to cache punctuation in Getopt::Declare
‘s cache
# File lib/Getopt/Declare.rb, line 434 def cachecode(ownerflag, itemcount) if itemcount > 1 " @cache['#{ownerflag}']['#{@text}'] = _PUNCT_['#{@text}']\n" else " unless @cache['#{ownerflag}']\n" + " @cache['#{ownerflag}'] = _PUNCT_['#{@text}'] || 1\n" + " end\n" end end
code(*t)
click to toggle source
Return string with code to process punctuation
# File lib/Getopt/Declare.rb, line 420 def code(*t) if t[0] pos1 = t[0].to_s else pos1 = '0' end " if @@m[#{pos1}] && !@@m[#{pos1}].empty? _PUNCT_['#{@text}'] = @@m[#{pos1}] end " end
matcher(g)
click to toggle source
Return regex that matches this punctuation
# File lib/Getopt/Declare.rb, line 415 def matcher(g) Arg::negflagpat + Regexp::quote(@text) end
ows(g)
click to toggle source
Helps build regex that matches parameters of flags Wraps parameter passed for #$1, etc. matching
# File lib/Getopt/Declare.rb, line 451 def ows(g) return '[\s\0]*(' + g + ')' unless @nows '(' + g + ')' end
trailer()
click to toggle source
Helps build regex that matches parameters of flags
# File lib/Getopt/Declare.rb, line 445 def trailer @text end