Class: Apply
- Inherits:
-
Combinator
- Object
- Combinator
- Apply
- Defined in:
- lib/hivemind/combinators.rb
Instance Attribute Summary collapse
-
#parser ⇒ Object
Returns the value of attribute parser.
-
#transformation ⇒ Object
readonly
Returns the value of attribute transformation.
Instance Method Summary collapse
-
#initialize(parser, &transformation) ⇒ Apply
constructor
A new instance of Apply.
- #parse(input, refs) ⇒ Object
Methods inherited from Combinator
Constructor Details
#initialize(parser, &transformation) ⇒ Apply
Returns a new instance of Apply.
173 174 175 |
# File 'lib/hivemind/combinators.rb', line 173 def initialize(parser, &transformation) @parser, @transformation = parser, transformation end |
Instance Attribute Details
#parser ⇒ Object
Returns the value of attribute parser.
170 171 172 |
# File 'lib/hivemind/combinators.rb', line 170 def parser @parser end |
#transformation ⇒ Object (readonly)
Returns the value of attribute transformation.
171 172 173 |
# File 'lib/hivemind/combinators.rb', line 171 def transformation @transformation end |
Instance Method Details
#parse(input, refs) ⇒ Object
177 178 179 180 181 |
# File 'lib/hivemind/combinators.rb', line 177 def parse(input, refs) success, result, remaining = @parser.parse(input, refs) result = @transformation.call(result) if success [success, result, remaining] end |