Class: Kaiseki::ListParser

Inherits:
Object show all
Includes:
Parseable
Defined in:
lib/parser_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Parseable

#&, #action, #and?, #cast, #filter, #list, #merge, #not!, #one_or_more, #optional, #override, #parse, #predicate?, #protect, #repeat, #set, #skip, #tag_error, #tag_result, #to_parseable, #validate, #zero_or_more, #|

Constructor Details

#initialize(expected, delimiter = ',') ⇒ ListParser

Returns a new instance of ListParser.

Raises:

  • (ArgumentError)


6
7
8
9
10
# File 'lib/parser_list.rb', line 6

def initialize expected, delimiter = ','
	raise ArgumentError, "expected must not be a predicate" if expected.predicate?
	@expected = expected
	@delimiter = delimiter
end

Instance Attribute Details

#delimiterObject (readonly)

Returns the value of attribute delimiter.



4
5
6
# File 'lib/parser_list.rb', line 4

def delimiter
  @delimiter
end

#expectedObject (readonly)

Returns the value of attribute expected.



4
5
6
# File 'lib/parser_list.rb', line 4

def expected
  @expected
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


12
13
14
# File 'lib/parser_list.rb', line 12

def eql? other
	other.is_a?(self.class) and other.expected == @expected and other.delimiter = @delimiter
end

#to_sObject



18
19
20
# File 'lib/parser_list.rb', line 18

def to_s
	"#{@expected}#{@delimiter} ..."
end