Class: CsvReader
- Inherits:
-
Object
- Object
- CsvReader
- Defined in:
- lib/lib_stats/csvreader.rb
Instance Attribute Summary collapse
-
#categories ⇒ Object
Returns the value of attribute categories.
-
#checkouts ⇒ Object
Returns the value of attribute checkouts.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
Instance Method Summary collapse
-
#initialize ⇒ CsvReader
constructor
A new instance of CsvReader.
- #read_in(csv_filename) ⇒ Object
Constructor Details
#initialize ⇒ CsvReader
Returns a new instance of CsvReader.
4 5 6 7 8 |
# File 'lib/lib_stats/csvreader.rb', line 4 def initialize @categories = [] @library_quantity @library_checkouts end |
Instance Attribute Details
#categories ⇒ Object
Returns the value of attribute categories.
2 3 4 |
# File 'lib/lib_stats/csvreader.rb', line 2 def categories @categories end |
#checkouts ⇒ Object
Returns the value of attribute checkouts.
2 3 4 |
# File 'lib/lib_stats/csvreader.rb', line 2 def checkouts @checkouts end |
#quantity ⇒ Object
Returns the value of attribute quantity.
2 3 4 |
# File 'lib/lib_stats/csvreader.rb', line 2 def quantity @quantity end |
Instance Method Details
#read_in(csv_filename) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/lib_stats/csvreader.rb', line 11 def read_in(csv_filename) CSV.foreach(csv_filename, headers: true) do |row| @categories << { name: row["Category"], quantity: row["Quantity"], checkouts: row["Checkouts"] } end return "reading #{csv_filename}" end |