Class: Optopus::CheckerContext
- Inherits:
-
Object
- Object
- Optopus::CheckerContext
- Defined in:
- lib/optopus.rb
Overview
DefinerContext
Class Method Summary collapse
Instance Method Summary collapse
- #ambiguous_argument(*args) ⇒ Object
- #ambiguous_option(*args) ⇒ Object
-
#initialize(value, &block) ⇒ CheckerContext
constructor
A new instance of CheckerContext.
- #invalid_argument(*args) ⇒ Object
- #invalid_option(*args) ⇒ Object
- #missing_argument(*args) ⇒ Object
- #needless_argument(*args) ⇒ Object
- #not_given(*args) ⇒ Object
- #parse_error(reason, *args) ⇒ Object
Constructor Details
#initialize(value, &block) ⇒ CheckerContext
Returns a new instance of CheckerContext.
65 66 67 68 |
# File 'lib/optopus.rb', line 65 def initialize(value, &block) @args = value ? [value] : [] (class<<self; self; end).send(:define_method, :evaluate, &block) end |
Class Method Details
.evaluate(args, pass, &block) ⇒ Object
61 62 63 |
# File 'lib/optopus.rb', line 61 def self.evaluate(args, pass, &block) self.new(args, &block).evaluate(pass) end |
Instance Method Details
#ambiguous_argument(*args) ⇒ Object
102 103 104 105 |
# File 'lib/optopus.rb', line 102 def ambiguous_argument(*args) args = @args if args.empty? raise OptionParser::AmbiguousArgument.new(*args) end |
#ambiguous_option(*args) ⇒ Object
77 78 79 80 |
# File 'lib/optopus.rb', line 77 def ambiguous_option(*args) args = @args if args.empty? raise OptionParser::AmbiguousOption.new(*args) end |
#invalid_argument(*args) ⇒ Object
97 98 99 100 |
# File 'lib/optopus.rb', line 97 def invalid_argument(*args) args = @args if args.empty? raise OptionParser::InvalidArgument.new(*args) end |
#invalid_option(*args) ⇒ Object
92 93 94 95 |
# File 'lib/optopus.rb', line 92 def invalid_option(*args) args = @args if args.empty? raise OptionParser::InvalidOption.new(*args) end |
#missing_argument(*args) ⇒ Object
87 88 89 90 |
# File 'lib/optopus.rb', line 87 def missing_argument(*args) args = @args if args.empty? raise OptionParser::MissingArgument.new(*args) end |
#needless_argument(*args) ⇒ Object
82 83 84 85 |
# File 'lib/optopus.rb', line 82 def needless_argument(*args) args = @args if args.empty? raise OptionParser::NeedlessArgument.new(*args) end |
#not_given(*args) ⇒ Object
107 108 109 110 |
# File 'lib/optopus.rb', line 107 def not_given(*args) args = @args if args.empty? raise OptionParser::NotGiven.new(*args) end |
#parse_error(reason, *args) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/optopus.rb', line 70 def parse_error(reason, *args) args = @args if args.empty? e = OptionParser::ParseError.new(*args) e.reason = reason raise e end |