Class: Eg::ArithmeticFixture

Inherits:
Fit::PrimitiveFixture show all
Defined in:
lib/eg/arithmetic_fixture.rb

Constant Summary

Constants inherited from Fit::Fixture

Fit::Fixture::GRAY, Fit::Fixture::GREEN, Fit::Fixture::RED, Fit::Fixture::YELLOW

Instance Attribute Summary

Attributes inherited from Fit::Fixture

#args, #counts, #listener, #summary

Instance Method Summary collapse

Methods inherited from Fit::PrimitiveFixture

#check, #check_boolean, #check_value, #parse_boolean, #parse_double, #parse_integer

Methods inherited from Fit::Fixture

camel, #check, #do_cells, #do_row, #do_table, #do_tables, #error, escape, #exception, #find_class, #fixture_name, #get_args_for_table, #get_linked_fixture_with_args, gray, #ignore, #info, #interpret_following_tables, #interpret_tables, label, metadata, #parse, #right, #total_errors, #totals, #wrong

Constructor Details

#initializeArithmeticFixture

Returns a new instance of ArithmeticFixture.



9
10
11
12
# File 'lib/eg/arithmetic_fixture.rb', line 9

def initialize
  super
  @x = @y = 0
end

Instance Method Details

#do_cell(cell, column_index) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/eg/arithmetic_fixture.rb', line 16

def do_cell cell, column_index
  case column_index
    when 0 then @x = parse_integer(cell);
    when 1 then @y = parse_integer(cell);
    when 2 then check(cell, parse_integer(cell), @x + @y)
    when 3 then check(cell, parse_integer(cell), @x - @y)
    when 4 then check(cell, parse_integer(cell), @x * @y)
    when 5 then check(cell, parse_integer(cell), @x / @y)
    else ignore(cell)
  end
end

#do_rows(rows) ⇒ Object



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

def do_rows rows
  super(rows.more) # skip column heads
end