Class: TruthTable

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

Instance Method Summary collapse

Constructor Details

#initialize(test_cases) ⇒ TruthTable

Returns a new instance of TruthTable.



3
4
5
# File 'lib/truth_table.rb', line 3

def initialize(test_cases)
  @test_cases = test_cases
end

Instance Method Details

#formatted_casesObject



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

def formatted_cases
  @test_cases.formatted("%2d) %s | %3d\n")
end

#formatted_input_to_condition_mapingObject



13
14
15
# File 'lib/truth_table.rb', line 13

def formatted_input_to_condition_maping
  @test_cases.formatted_input_to_condition_maping("%s <= %s\n")
end

#table_headerObject



17
18
19
# File 'lib/truth_table.rb', line 17

def table_header
  "    %s | output" % @test_cases.input_identifiers.join(" ")
end

#to_sObject



7
8
9
10
11
# File 'lib/truth_table.rb', line 7

def to_s
  formatted_input_to_condition_maping + "\n" +
    table_header + "\n" +
    formatted_cases + "\n"
end