Class: ADT::CaseRecorder

Inherits:
Object
  • Object
show all
Defined in:
lib/adt/case_recorder.rb

Instance Method Summary collapse

Constructor Details

#initializeCaseRecorder

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_casesObject



12
13
14
# File 'lib/adt/case_recorder.rb', line 12

def _church_cases
  @tape.map { |xs| xs[0..1] }
end

#_implementationsObject



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