Class: Pione::Util::ExceptionAtom
- Inherits:
-
Parslet::Atoms::Base
- Object
- Parslet::Atoms::Base
- Pione::Util::ExceptionAtom
- Defined in:
- lib/pione/util/parslet-extension.rb
Instance Method Summary collapse
-
#initialize(atom, exception) ⇒ ExceptionAtom
constructor
A new instance of ExceptionAtom.
- #to_s_inner(prec) ⇒ Object
- #try(source, context) ⇒ Object
Constructor Details
#initialize(atom, exception) ⇒ ExceptionAtom
Returns a new instance of ExceptionAtom.
56 57 58 59 |
# File 'lib/pione/util/parslet-extension.rb', line 56 def initialize(atom, exception) @atom = atom @exception = exception end |
Instance Method Details
#to_s_inner(prec) ⇒ Object
72 73 74 |
# File 'lib/pione/util/parslet-extension.rb', line 72 def to_s_inner(prec) "EXCEPTION" end |
#try(source, context) ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/pione/util/parslet-extension.rb', line 61 def try(source, context) success, value = result = @atom.apply(source, context) if success esuccess, _ = @exception.apply(source, context) if esuccess return result end end return result end |