Class: Factbook::Comparisons
- Inherits:
-
Object
- Object
- Factbook::Comparisons
- Defined in:
- lib/factbook-fields/comparisons.rb
Defined Under Namespace
Classes: Comparison
Class Method Summary collapse
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(comps) ⇒ Comparisons
constructor
A new instance of Comparisons.
- #size ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(comps) ⇒ Comparisons
Returns a new instance of Comparisons.
32 33 34 |
# File 'lib/factbook-fields/comparisons.rb', line 32 def initialize( comps ) @comps = comps end |
Class Method Details
.read_csv(path) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/factbook-fields/comparisons.rb', line 11 def self.read_csv( path ) rows = CsvHash.read( path ) pp rows recs = [] rows.each do |row| pp row rec = Comparison.new rec.num = row['Num'].strip.to_i ## remove leading n trailing whitespaces rec.category = row['Category'].strip rec.name = row['Name'].strip pp rec recs << rec end new( recs ) end |
Instance Method Details
#each ⇒ Object
38 39 40 |
# File 'lib/factbook-fields/comparisons.rb', line 38 def each @comps.each {|comp| yield( comp ) } end |
#size ⇒ Object
36 |
# File 'lib/factbook-fields/comparisons.rb', line 36 def size() @comps.size; end |
#to_a ⇒ Object
42 43 44 |
# File 'lib/factbook-fields/comparisons.rb', line 42 def to_a @comps.collect {|comp| comp.num } ## return array of nums -- return something else - why? why not? end |