Class: Walrat::ProcParslet
- Defined in:
- lib/walrat/proc_parslet.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
-
#initialize(proc) ⇒ ProcParslet
constructor
A new instance of ProcParslet.
- #parse(string, options = {}) ⇒ Object
Methods inherited from Parslet
Methods included from Memoizing
#check_left_recursion, #memoizing_parse
Methods included from ParsletCombining
#&, #>>, #and?, #and_predicate, #choice, #memoizing_parse, #merge, #not!, #not_predicate, #omission, #one_or_more, #optional, #repeat, #repeat_with_default, #repetition, #repetition_with_default, #sequence, #skip, #zero_or_more, #zero_or_one, #|
Constructor Details
#initialize(proc) ⇒ ProcParslet
Returns a new instance of ProcParslet.
29 30 31 32 |
# File 'lib/walrat/proc_parslet.rb', line 29 def initialize proc raise ArgumentError, 'nil proc' if proc.nil? self.expected_proc = proc end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
27 28 29 |
# File 'lib/walrat/proc_parslet.rb', line 27 def hash @hash end |
Instance Method Details
#eql?(other) ⇒ Boolean
39 40 41 |
# File 'lib/walrat/proc_parslet.rb', line 39 def eql?(other) other.instance_of? ProcParslet and other.expected_proc == @expected_proc end |
#parse(string, options = {}) ⇒ Object
34 35 36 37 |
# File 'lib/walrat/proc_parslet.rb', line 34 def parse string, = {} raise ArgumentError, 'nil string' if string.nil? @expected_proc.call string, end |