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.
3 4 5 |
# File 'lib/truth_table.rb', line 3 def initialize(test_cases) @test_cases = test_cases end |
Instance Method Details
#formatted_cases ⇒ Object
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_maping ⇒ Object
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_header ⇒ Object
17 18 19 |
# File 'lib/truth_table.rb', line 17 def table_header " %s | output" % @test_cases.input_identifiers.join(" ") end |
#to_s ⇒ Object
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 |