Class: Samovar::Many

Inherits:
Object
  • Object
show all
Defined in:
lib/samovar/many.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, description, stop: /^-/) ⇒ Many

Returns a new instance of Many.



23
24
25
26
27
# File 'lib/samovar/many.rb', line 23

def initialize(key, description, stop: /^-/)
	@key = key
	@description = description
	@stop = stop
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



29
30
31
# File 'lib/samovar/many.rb', line 29

def key
  @key
end

Instance Method Details

#parse(input) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/samovar/many.rb', line 39

def parse(input)
	if @stop and stop_index = input.index{|item| @stop === item}
		input.shift(stop_index)
	else
		input.shift(input.size)
	end
end

#to_aObject



35
36
37
# File 'lib/samovar/many.rb', line 35

def to_a
	[to_s, @description]
end

#to_sObject



31
32
33
# File 'lib/samovar/many.rb', line 31

def to_s
	"<#{key}...>"
end