Module: OptionBinder::Arguable
- Extended by:
- Forwardable
- Defined in:
- lib/optbind.rb,
lib/optbind/mode.rb
Class Method Summary collapse
Instance Method Summary collapse
- #binder(opts = {}, &blk) ⇒ Object (also: #define, #define_and_bind, #bind)
- #binder=(bind) ⇒ Object
- #define_and_parse(opts = {}, &blk) ⇒ Object (also: #bind_and_parse)
- #define_and_parse!(opts = {}, &blk) ⇒ Object (also: #bind_and_parse!)
- #order(&blk) ⇒ Object
- #order!(&blk) ⇒ Object
- #parse ⇒ Object
- #parse! ⇒ Object
- #permute ⇒ Object
- #permute! ⇒ Object
Class Method Details
.extend_object(o) ⇒ Object
267 268 269 270 |
# File 'lib/optbind.rb', line 267 def self.extend_object(o) super and return unless o.singleton_class.included_modules.include? OptionParser::Arguable %i(order! permute!).each { |m| o.define_singleton_method(m) { raise 'unsupported' }} end |
Instance Method Details
#binder(opts = {}, &blk) ⇒ Object Also known as: define, define_and_bind, bind
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/optbind.rb', line 276 def binder(opts = {}, &blk) unless @optbind if opts[:to] == :locals target, bind = TOPLEVEL_BINDING, :to_local_variables else target = opts[:target] || opts[:to] bind = (:to_local_variables if opts[:locals]) || opts[:bind] || ("to_#{opts[:via]}".to_sym if opts[:via]) end @optbind = OptionBinder.new parser: opts[:parser], target: target, bind: bind end @optbind.parser.default_argv = self @optbind.instance_eval &blk if blk self. = @optbind.parser if respond_to? :options= @optbind end |
#binder=(bind) ⇒ Object
272 273 274 |
# File 'lib/optbind.rb', line 272 def binder=(bind) @optbind = bind end |
#define_and_parse(opts = {}, &blk) ⇒ Object Also known as: bind_and_parse
302 303 304 |
# File 'lib/optbind.rb', line 302 def define_and_parse(opts = {}, &blk) define(opts, &blk) and parse end |
#define_and_parse!(opts = {}, &blk) ⇒ Object Also known as: bind_and_parse!
308 309 310 |
# File 'lib/optbind.rb', line 308 def define_and_parse!(opts = {}, &blk) define(opts, &blk) and parse! end |
#order(&blk) ⇒ Object
21 22 23 |
# File 'lib/optbind/mode.rb', line 21 def order(&blk) binder.order self, &blk end |
#order!(&blk) ⇒ Object
25 26 27 |
# File 'lib/optbind/mode.rb', line 25 def order!(&blk) binder.order! self, &blk end |
#parse ⇒ Object
314 315 316 |
# File 'lib/optbind.rb', line 314 def parse binder.parse self end |
#parse! ⇒ Object
318 319 320 |
# File 'lib/optbind.rb', line 318 def parse! binder.parse! self end |
#permute ⇒ Object
29 30 31 |
# File 'lib/optbind/mode.rb', line 29 def permute binder.permute self end |
#permute! ⇒ Object
33 34 35 |
# File 'lib/optbind/mode.rb', line 33 def permute! binder.permute! self end |