class Samovar::Many
Attributes
Public Class Methods
Source
# File vendor/bundle/ruby/3.4.0/gems/samovar-2.3.0/lib/samovar/many.rb, line 8 def initialize(key, description = nil, stop: /^-/, default: nil, required: false) @key = key @description = description @stop = stop @default = default @required = required end
Public Instance Methods
Source
# File vendor/bundle/ruby/3.4.0/gems/samovar-2.3.0/lib/samovar/many.rb, line 38 def parse(input, parent = nil, default = nil) if @stop and stop_index = input.index{|item| @stop === item} input.shift(stop_index) elsif input.any? input.shift(input.size) elsif default ||= @default return default elsif @required raise MissingValueError.new(parent, self) end end
Source
# File vendor/bundle/ruby/3.4.0/gems/samovar-2.3.0/lib/samovar/many.rb, line 26 def to_a usage = [to_s, @description] if @default usage << "(default: #{@default.inspect})" elsif @required usage << "(required)" end return usage end
Source
# File vendor/bundle/ruby/3.4.0/gems/samovar-2.3.0/lib/samovar/many.rb, line 22 def to_s "<#{key}...>" end