module OptionBinder::Arguable

Public Class Methods

extend_object(o) click to toggle source
Calls superclass method
# 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

Public Instance Methods

bind(opts = {}, &blk)
Alias for: binder
bind_and_parse(opts = {}, &blk)
Alias for: define_and_parse
bind_and_parse!(opts = {}, &blk)
Alias for: define_and_parse!
binder(opts = {}, &blk) click to toggle source
# 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.options = @optbind.parser if respond_to? :options=
  @optbind
end
Also aliased as: define, define_and_bind, bind
binder=(bind) click to toggle source
# File lib/optbind.rb, line 272
def binder=(bind)
  @optbind = bind
end
define(opts = {}, &blk)
Alias for: binder
define_and_bind(opts = {}, &blk)
Alias for: binder
define_and_parse(opts = {}, &blk) click to toggle source
# File lib/optbind.rb, line 302
def define_and_parse(opts = {}, &blk)
  define(opts, &blk) and parse
end
Also aliased as: bind_and_parse
define_and_parse!(opts = {}, &blk) click to toggle source
# File lib/optbind.rb, line 308
def define_and_parse!(opts = {}, &blk)
  define(opts, &blk) and parse!
end
Also aliased as: bind_and_parse!
order(&blk) click to toggle source
# File lib/optbind/mode.rb, line 21
def order(&blk)
  binder.order self, &blk
end
order!(&blk) click to toggle source
# File lib/optbind/mode.rb, line 25
def order!(&blk)
  binder.order! self, &blk
end
parse() click to toggle source
# File lib/optbind.rb, line 314
def parse
  binder.parse self
end
parse!() click to toggle source
# File lib/optbind.rb, line 318
def parse!
  binder.parse! self
end
permute() click to toggle source
# File lib/optbind/mode.rb, line 29
def permute
  binder.permute self
end
permute!() click to toggle source
# File lib/optbind/mode.rb, line 33
def permute!
  binder.permute! self
end