Class: CsvReader

Inherits:
Object
  • Object
show all
Defined in:
lib/lib_stats/csvreader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCsvReader

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

#categoriesObject

Returns the value of attribute categories.



2
3
4
# File 'lib/lib_stats/csvreader.rb', line 2

def categories
  @categories
end

#checkoutsObject

Returns the value of attribute checkouts.



2
3
4
# File 'lib/lib_stats/csvreader.rb', line 2

def checkouts
  @checkouts
end

#quantityObject

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