Class: OptparseLite::OptParser::Response
Instance Method Summary
collapse
#dashes
Methods included from HelpHelper
#cmd, #hdr, #help_requested?, #looks_like_header?, #prefix, #txt
Constructor Details
#initialize(hack_start = nil) ⇒ Response
Returns a new instance of Response.
775
776
777
778
|
# File 'lib/optparse-lite.rb', line 775
def initialize hack_start=nil
super(hack_start) if hack_start
@memoish = {}
end
|
Instance Method Details
#all_indexes(sym) ⇒ Object
779
780
781
|
# File 'lib/optparse-lite.rb', line 779
def all_indexes sym
each_with_index.map{|(v,i)| v.error_type == sym ? i : nil }.compact
end
|
#argument_not_allowed(spec, key, val) ⇒ Object
782
783
784
785
786
|
# File 'lib/optparse-lite.rb', line 782
def argument_not_allowed spec, key, val
push Error.new(:argument_not_allowed,
code(dashes(key))<<" does not take an arguement (#{val.inspect})",
:norm_key => spec.normalized_key)
end
|
#delete(sym) ⇒ Object
787
788
789
790
791
792
793
|
# File 'lib/optparse-lite.rb', line 787
def delete sym
idxs = all_indexes(sym)
case idxs.size
when 0; nil
when 1; delete_at(idxs.first)
end
end
|
#errors ⇒ Object
794
|
# File 'lib/optparse-lite.rb', line 794
def errors; self end
|
#required_argument_missing(spec, key) ⇒ Object
795
796
797
798
799
800
|
# File 'lib/optparse-lite.rb', line 795
def required_argument_missing spec, key
push Error.new(:required_argument_missing,
code(dashes(key))<<" requires a parameter ("<<
"#{spec.cannonical_name})",
:norm_key => spec.normalized_key)
end
|
#unrecognized_parameter(key, value) ⇒ Object
801
802
803
|
# File 'lib/optparse-lite.rb', line 801
def unrecognized_parameter key, value
memoish(:unrec_param){ UnparsedParamters.new }[key] = value
end
|
#valid? ⇒ Boolean
804
|
# File 'lib/optparse-lite.rb', line 804
def valid?; empty? end
|