Class: ADT::CaseRecorder
- Inherits:
-
Object
- Object
- ADT::CaseRecorder
- Defined in:
- lib/adt/case_recorder.rb
Instance Method Summary collapse
- #_church_cases ⇒ Object
- #_implementations ⇒ Object
-
#define_case(sym, *args) ⇒ Object
Defines a case for an ADT.
-
#initialize ⇒ CaseRecorder
constructor
A new instance of CaseRecorder.
Constructor Details
#initialize ⇒ CaseRecorder
Returns a new instance of CaseRecorder.
8 9 10 |
# File 'lib/adt/case_recorder.rb', line 8 def initialize @tape = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &blk) ⇒ Object (private)
Records EVERYTHING
33 34 35 |
# File 'lib/adt/case_recorder.rb', line 33 def method_missing(sym, *args, &blk) record(sym, *args, &blk) end |
Instance Method Details
#_church_cases ⇒ Object
12 13 14 |
# File 'lib/adt/case_recorder.rb', line 12 def _church_cases @tape.map { |xs| xs[0..1] } end |
#_implementations ⇒ Object
16 17 18 19 |
# File 'lib/adt/case_recorder.rb', line 16 def _implementations # Implementations have a symbol and a block argument @tape.map { |xs| [xs[0], xs[2]] } end |
#define_case(sym, *args) ⇒ Object
Defines a case for an ADT.
22 23 24 |
# File 'lib/adt/case_recorder.rb', line 22 def define_case(sym, *args) record(sym, *args) end |