Class: Fat::Equals
- Inherits:
-
Fit::PrimitiveFixture
- Object
- Fit::Fixture
- Fit::PrimitiveFixture
- Fat::Equals
- Defined in:
- lib/fat/equals.rb
Constant Summary
Constants inherited from Fit::Fixture
Fit::Fixture::GRAY, Fit::Fixture::GREEN, Fit::Fixture::RED, Fit::Fixture::YELLOW
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#heads ⇒ Object
Returns the value of attribute heads.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Attributes inherited from Fit::Fixture
#args, #counts, #listener, #summary
Instance Method Summary collapse
- #do_cell(cell, column_index) ⇒ Object
- #do_rows(rows) ⇒ Object
- #parse(string, klass) ⇒ Object
- #print(value) ⇒ Object
- #type(name) ⇒ Object
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, #initialize, #interpret_following_tables, #interpret_tables, label, metadata, #right, #total_errors, #totals, #wrong
Constructor Details
This class inherits a constructor from Fit::Fixture
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
14 15 16 |
# File 'lib/fat/equals.rb', line 14 def adapter @adapter end |
#heads ⇒ Object
Returns the value of attribute heads.
14 15 16 |
# File 'lib/fat/equals.rb', line 14 def heads @heads end |
#x ⇒ Object
Returns the value of attribute x.
14 15 16 |
# File 'lib/fat/equals.rb', line 14 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
14 15 16 |
# File 'lib/fat/equals.rb', line 14 def y @y end |
Instance Method Details
#do_cell(cell, column_index) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fat/equals.rb', line 21 def do_cell cell, column_index begin head = @heads.at(column_index).text[0..0] case head when 't' then @adapter = type(cell.text) when 'x' then @x = @adapter.parse(cell.text) when 'y' then @y = @adapter.parse(cell.text) when '=' then check_boolean(cell, @adapter.equals(@x, @y)) when '?' then cell.add_to_body(Fit::Fixture.gray("x: #{print(@x)} y: #{print(@y)}")) else raise "Don't do #{head}" end rescue Exception => e exception cell, e end end |
#do_rows(rows) ⇒ Object
16 17 18 19 |
# File 'lib/fat/equals.rb', line 16 def do_rows rows @heads = rows.parts super rows.more end |
#parse(string, klass) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/fat/equals.rb', line 48 def parse string, klass return Money.new(string) if klass == Money return Float(string) if klass == Float return Integer(string) if klass == Integer super end |
#print(value) ⇒ Object
55 |
# File 'lib/fat/equals.rb', line 55 def print value; @adapter.to_s value; end |
#type(name) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fat/equals.rb', line 37 def type name; case name when 'date' then Fit::TypeAdapter.on(self, ParseDate) when 'integer' then Fit::TypeAdapter.on(self, Integer) when 'real' then Fit::TypeAdapter.on(self, Float) when 'scientific' then Fit::TypeAdapter.on(self, Fit::ScientificDouble) when 'money' then Fit::TypeAdapter.on(self, Money) else Fit::TypeAdapter.for(self, '', false) end end |