Class: Samovar::Split

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, description, marker: '--') ⇒ Split

Returns a new instance of Split.



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

def initialize(key, description, marker: '--')
	@key = key
	@description = description
	@marker = marker
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



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

def key
  @key
end

Instance Method Details

#parse(input) ⇒ Object



39
40
41
42
43
# File 'lib/samovar/split.rb', line 39

def parse(input)
	if offset = input.index(@marker)
		input.pop(input.size - offset).tap(&:shift)
	end
end

#to_aObject



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

def to_a
	[to_s, @description]
end

#to_sObject



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

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