Class: Strop::Result
- Inherits:
-
Array
- Object
- Array
- Strop::Result
- Defined in:
- lib/strop.rb
Overview
Parse result containing options, arguments, and separators; Returned by ‘parse` Result[opt1, arg1, Sep] #=> [Opt(…), Arg(…), Sep]
Instance Method Summary collapse
- #[](k) ⇒ Object
- #args ⇒ Object
- #opts ⇒ Object
-
#rest ⇒ Object
of Opt, Arg, Sep.
Instance Method Details
#[](k) ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/strop.rb', line 97 def [](k, ...) case k in [String | Symbol => name] then opts.select{ it.decl.names.include? Strop.name_from_symbol name } in String | Symbol then find{ Opt === it && it.decl.names.member?(Strop.name_from_symbol k) } else super(k, ...) end end |
#args ⇒ Object
95 |
# File 'lib/strop.rb', line 95 def args = Result.new(select { Arg === it }) |
#opts ⇒ Object
96 |
# File 'lib/strop.rb', line 96 def opts = Result.new(select { Opt === it }) |
#rest ⇒ Object
of Opt, Arg, Sep
94 |
# File 'lib/strop.rb', line 94 def rest = drop_while{ it != Sep }.drop(1) # args after sep |