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.



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

def initialize(test_cases)
  @test_cases = test_cases
end

Instance Method Details

#formatted_casesObject



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

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

#formatted_input_to_condition_mapingObject



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

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

#table_headerObject



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

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

#to_sObject



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

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