Module: OptionBinder::Arguable
- Defined in:
- lib/optbind.rb
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!)
- #order!(&blk) ⇒ Object
- #parse! ⇒ Object
- #parser ⇒ Object
- #permute! ⇒ Object
Instance Method Details
#binder(opts = {}, &blk) ⇒ Object Also known as: define, define_and_bind, bind
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/optbind.rb', line 246 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.instance_eval &blk if blk self. = @optbind.parser @optbind end |
#binder=(bind) ⇒ Object
237 238 239 240 241 242 243 244 |
# File 'lib/optbind.rb', line 237 def binder=(bind) unless @optbind = bind class << self undef_method(:binder) undef_method(:binder=) end end end |
#define_and_parse!(opts = {}, &blk) ⇒ Object Also known as: bind_and_parse!
267 268 269 270 |
# File 'lib/optbind.rb', line 267 def define_and_parse!(opts = {}, &blk) define opts, &blk parse! end |
#order!(&blk) ⇒ Object
278 279 280 |
# File 'lib/optbind.rb', line 278 def order!(&blk) binder.order! self, &blk end |
#parse! ⇒ Object
286 287 288 |
# File 'lib/optbind.rb', line 286 def parse! binder.parse! self end |
#parser ⇒ Object
274 275 276 |
# File 'lib/optbind.rb', line 274 def parser self. end |
#permute! ⇒ Object
282 283 284 |
# File 'lib/optbind.rb', line 282 def permute! binder.permute! self end |