lib_stats 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,31 @@
1
+ class Category
2
+ attr_reader :name, :quantity, :checkouts
3
+
4
+
5
+ def initialize(library, args = {})
6
+ @library = library
7
+ @name = args[:name] || "Category Name"
8
+ @quantity = args[:quantity].to_i || 0
9
+ @checkouts = args[:checkouts].to_i || 0
10
+ end
11
+
12
+ def percent_of_total
13
+ return (@quantity.fdiv(@library.quantity) * 100).round(1)
14
+ end
15
+
16
+
17
+ def percent_of_checkouts
18
+ return (@checkouts.fdiv(@library.checkouts) * 100).round(1)
19
+ end
20
+
21
+
22
+ def performance
23
+ return @checkouts.fdiv(@quantity).round(3)
24
+ end
25
+
26
+
27
+
28
+
29
+
30
+
31
+ end
@@ -0,0 +1,22 @@
1
+ class CategoryBuilder
2
+
3
+ def initialize
4
+
5
+ end
6
+
7
+ def build(library, csv_file)
8
+
9
+ csvreader = CsvReader.new
10
+ csvreader.read_in(csv_file)
11
+
12
+ category_array = []
13
+ csvreader.categories.each do |hash|
14
+ category_array << Category.new(library, hash)
15
+ end
16
+
17
+ return category_array
18
+ end
19
+
20
+
21
+
22
+ end
@@ -0,0 +1,21 @@
1
+ class CsvReader
2
+ attr_accessor :categories, :quantity, :checkouts
3
+
4
+ def initialize
5
+ @categories = []
6
+ @library_quantity
7
+ @library_checkouts
8
+ end
9
+
10
+
11
+ def read_in(csv_filename)
12
+ CSV.foreach(csv_filename, headers: true) do |row|
13
+ @categories << { name: row["Category"],
14
+ quantity: row["Quantity"],
15
+ checkouts: row["Checkouts"] }
16
+ end
17
+
18
+ return "reading #{csv_filename}"
19
+ end
20
+
21
+ end
@@ -0,0 +1,17 @@
1
+ class Library
2
+ attr_accessor :name, :quantity, :checkouts
3
+
4
+ def initialize(args= {})
5
+ @name = args[:name] || librarysoup
6
+ @quantity = args[:quantity] || 0
7
+ @checkouts = args[:checkouts] || 0
8
+ end
9
+
10
+
11
+ def performance
12
+ return @checkouts.fdiv(@quantity).round(3)
13
+ end
14
+
15
+
16
+
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lib_stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -35,6 +35,10 @@ extensions: []
35
35
  extra_rdoc_files: []
36
36
  files:
37
37
  - lib/lib_stats.rb
38
+ - lib/lib_stats/category.rb
39
+ - lib/lib_stats/categorybuilder.rb
40
+ - lib/lib_stats/csvreader.rb
41
+ - lib/lib_stats/library.rb
38
42
  homepage: http://rubygems.org/gems/lib_stats
39
43
  licenses: []
40
44
  post_install_message: