Class: Strop::Result

Inherits:
Array
  • Object
show all
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

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

#argsObject



95
# File 'lib/strop.rb', line 95

def args = Result.new(select { Arg === it })

#optsObject



96
# File 'lib/strop.rb', line 96

def opts = Result.new(select { Opt === it })

#restObject

of Opt, Arg, Sep



94
# File 'lib/strop.rb', line 94

def rest = drop_while{ it != Sep }.drop(1) # args after sep