Class: Eg::ColumnIndex
- Inherits:
-
Fit::RowFixture
- Object
- Fit::Fixture
- Fit::ColumnFixture
- Fit::RowFixture
- Eg::ColumnIndex
- Defined in:
- lib/eg/column_index.rb
Defined Under Namespace
Classes: Column
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::RowFixture
Attributes inherited from Fit::Fixture
#args, #counts, #listener, #summary
Instance Method Summary collapse
- #do_rows(rows) ⇒ Object
- #get_target_class ⇒ Object
- #parse(string, klass) ⇒ Object
- #parse_class(name) ⇒ Object
- #query ⇒ Object
Methods inherited from Fit::RowFixture
Methods inherited from Fit::ColumnFixture
#check, #do_cell, #do_row, #execute, #reset
Methods inherited from Fit::Fixture
camel, #check, #do_cell, #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::RowFixture
Instance Method Details
#do_rows(rows) ⇒ Object
11 12 13 14 |
# File 'lib/eg/column_index.rb', line 11 def do_rows rows @rows = rows super end |
#get_target_class ⇒ Object
54 |
# File 'lib/eg/column_index.rb', line 54 def get_target_class; Column; end |
#parse(string, klass) ⇒ Object
56 57 58 59 |
# File 'lib/eg/column_index.rb', line 56 def parse string, klass return parse_class(string) if klass == Class super end |
#parse_class(name) ⇒ Object
61 62 63 |
# File 'lib/eg/column_index.rb', line 61 def parse_class name @@loader.find_class(name) end |
#query ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/eg/column_index.rb', line 16 def query # first find what classes are mentioned in the table... names = Set.new column_index = 0 cell = @rows.parts until cell.nil? break if cell.text == 'className' column_index += 1 cell = cell.more end row = @rows.more until row.nil? names.add row.at(0, column_index).text row = row.more end # ...then find the columns in these classes columns = [] names.each do |name| obj = @@loader.find_class(name).new # Ruby 1.9 returns method names as symbols attributes = (obj.methods - Object.new.methods).collect {|a| a.to_s} setters = attributes.dup.delete_if {|a| a[-1..-1] != "="} attributes -= setters setters.each do |s| getter = s[0..-2] if attributes.include? getter attributes.delete getter columns << Column.create(obj, getter) end end attributes.each do |m| meth = obj.method(m.to_sym) columns << Column.create(obj, "#{m}()") if meth.arity.zero? end end columns end |