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
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/optbind.rb', line 222 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
213 214 215 216 217 218 219 220 |
# File 'lib/optbind.rb', line 213 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!
243 244 245 246 |
# File 'lib/optbind.rb', line 243 def define_and_parse!(opts = {}, &blk) define opts, &blk parse! end |
#order!(&blk) ⇒ Object
254 255 256 |
# File 'lib/optbind.rb', line 254 def order!(&blk) binder.order! self, &blk end |
#parse! ⇒ Object
262 263 264 |
# File 'lib/optbind.rb', line 262 def parse! binder.parse! self end |
#parser ⇒ Object
250 251 252 |
# File 'lib/optbind.rb', line 250 def parser self. end |
#permute! ⇒ Object
258 259 260 |
# File 'lib/optbind.rb', line 258 def permute! binder.permute! self end |