Class: Kaiseki::RepeatParser
- Includes:
- Parseable
- Defined in:
- lib/parser_repeat.rb
Instance Attribute Summary collapse
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
-
#initialize(expected, min, max = nil) ⇒ RepeatParser
constructor
A new instance of RepeatParser.
- #to_s ⇒ Object
Methods included from Parseable
#&, #action, #and?, #cast, #filter, #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, min, max = nil) ⇒ RepeatParser
Returns a new instance of RepeatParser.
6 7 8 9 10 11 |
# File 'lib/parser_repeat.rb', line 6 def initialize expected, min, max = nil raise ArgumentError, "expected must not be a predicate" if expected.predicate? @expected = expected.to_parseable @min = min @max = max end |
Instance Attribute Details
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
4 5 6 |
# File 'lib/parser_repeat.rb', line 4 def expected @expected end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
4 5 6 |
# File 'lib/parser_repeat.rb', line 4 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
4 5 6 |
# File 'lib/parser_repeat.rb', line 4 def min @min end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
13 14 15 |
# File 'lib/parser_repeat.rb', line 13 def eql? other other.is_a?(self.class) and other.expected == @expected and other.min == @min and other.max == @max end |
#to_s ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/parser_repeat.rb', line 19 def to_s if @max @expected.to_s + " [#{@min}..#{@max}]" else @expected.to_s + " [#{@min}+]" end end |