Class: Factbook::Comparisons
- Inherits:
-
Object
- Object
- Factbook::Comparisons
- Defined in:
- lib/factbook-readers/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.
33 34 35 |
# File 'lib/factbook-readers/comparisons.rb', line 33 def initialize( comps ) @comps = comps end |
Class Method Details
.read_csv(path) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/factbook-readers/comparisons.rb', line 12 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
39 40 41 |
# File 'lib/factbook-readers/comparisons.rb', line 39 def each @comps.each {|comp| yield( comp ) } end |
#size ⇒ Object
37 |
# File 'lib/factbook-readers/comparisons.rb', line 37 def size() @comps.size; end |
#to_a ⇒ Object
43 44 45 |
# File 'lib/factbook-readers/comparisons.rb', line 43 def to_a @comps.collect {|comp| comp.num } ## return array of nums -- return something else - why? why not? end |