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.



7
8
9
# File 'lib/adt/case_recorder.rb', line 7

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



32
33
34
# File 'lib/adt/case_recorder.rb', line 32

def method_missing(sym, *args, &blk)
  record(sym, *args, &blk)
end

Instance Method Details

#_church_casesObject



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

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

#_implementationsObject



15
16
17
18
# File 'lib/adt/case_recorder.rb', line 15

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.



21
22
23
# File 'lib/adt/case_recorder.rb', line 21

def define_case(sym, *args)
  record(sym, *args)
end