Class: TruthTable
- Inherits:
-
Object
- Object
- TruthTable
- Defined in:
- lib/truth_table.rb
Instance Method Summary collapse
- #formatted_cases ⇒ Object
- #formatted_input_to_condition_maping ⇒ Object
-
#initialize(test_cases) ⇒ TruthTable
constructor
A new instance of TruthTable.
- #table_header ⇒ Object
- #to_s ⇒ Object
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_cases ⇒ Object
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_maping ⇒ Object
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_header ⇒ Object
16 17 18 |
# File 'lib/truth_table.rb', line 16 def table_header " %s | output" % @test_cases.input_identifiers.join(" ") end |
#to_s ⇒ Object
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 |