lib_stats 0.0.5

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.
Files changed (2) hide show
  1. data/lib/libraryapp.rb +85 -0
  2. metadata +62 -0
data/lib/libraryapp.rb ADDED
@@ -0,0 +1,85 @@
1
+ require 'csv'
2
+ require_relative 'librarystatistics/category.rb'
3
+ require_relative 'librarystatistics/library.rb'
4
+ require_relative 'librarystatistics/csvreader.rb'
5
+ require_relative 'librarystatistics/categorybuilder.rb'
6
+
7
+ class LibraryApp
8
+ attr_accessor :name, :category_array, :library, :loser_array
9
+
10
+ def initialize(args = {})
11
+
12
+ @library = Library.new({name: args[:name],
13
+ quantity: args[:quantity],
14
+ checkouts: args[:checkouts]})
15
+
16
+ inputfile = CategoryBuilder.new
17
+ @category_array = inputfile.build(@library, args[:file])
18
+
19
+ @category_array.each do |count|
20
+ @library.quantity += count.quantity
21
+ @library.checkouts += count.checkouts
22
+
23
+ end
24
+
25
+
26
+ end
27
+
28
+
29
+ def display
30
+ output = ""
31
+ @category_array.each do |stuff|
32
+ output += "#{stuff.name} \n"
33
+ output += "Quantity: #{stuff.quantity} \n"
34
+ output += "% of Total Books: #{stuff.percent_of_total} \n"
35
+ output += "Checkouts: #{stuff.checkouts} \n"
36
+ output += "% of Total Checkouts: #{stuff.percent_of_checkouts} \n"
37
+ output += "Performance (average number of checkouts per book in category): #{stuff.performance} \n"
38
+ output += "------------- \n"
39
+ end
40
+
41
+ return output
42
+
43
+ end
44
+
45
+
46
+ def winners
47
+ best_score = 0.01
48
+ loser_array = []
49
+ winner_array = []
50
+ output = ""
51
+
52
+ @category_array.each do |stuff|
53
+
54
+ #collect best performers
55
+ if stuff.performance > best_score
56
+ best_score = stuff.performance
57
+ winner_array.clear
58
+ winner_array << stuff
59
+ end
60
+
61
+ #collect worst performers
62
+ if stuff.percent_of_checkouts == 0
63
+ loser_array << stuff
64
+ end
65
+
66
+ end
67
+
68
+ output += "Losers:"
69
+ loser_array.each do |loser|
70
+ output += "#{loser.name} /n"
71
+ end
72
+
73
+ output += "Winner:"
74
+ winner_array.each do |winner|
75
+ output += "#{winner.name}"
76
+ end
77
+
78
+ puts output
79
+ return output
80
+
81
+
82
+ end
83
+
84
+
85
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lib_stats
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Cheri Allen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: require_relative
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: A gem to track the performance of different categories of books in a
31
+ library
32
+ email: cherimarie@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - lib/libraryapp.rb
38
+ homepage: http://rubygems.org/gems/lib_stats
39
+ licenses: []
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubyforge_project:
58
+ rubygems_version: 1.8.24
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: Performance statistics for libraries
62
+ test_files: []