Class: ItemStats
- Inherits:
-
Object
- Object
- ItemStats
- Defined in:
- lib/itemStats.rb
Instance Method Summary collapse
-
#initialize(taggedItems, untaggedItems, readTaggedItems, readUntaggedItems) ⇒ ItemStats
constructor
A new instance of ItemStats.
- #print ⇒ Object
- #printGeneralStats ⇒ Object
Constructor Details
#initialize(taggedItems, untaggedItems, readTaggedItems, readUntaggedItems) ⇒ ItemStats
Returns a new instance of ItemStats.
5 6 7 8 9 10 |
# File 'lib/itemStats.rb', line 5 def initialize(taggedItems, untaggedItems, readTaggedItems, readUntaggedItems) @taggedItems = taggedItems @untaggedItems = untaggedItems @readTaggedItems = readTaggedItems @readUntaggedItems = readUntaggedItems end |
Instance Method Details
#print ⇒ Object
12 13 14 |
# File 'lib/itemStats.rb', line 12 def print printGeneralStats end |
#printGeneralStats ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/itemStats.rb', line 16 def printGeneralStats tagged = @taggedItems.length untagged = @untaggedItems.length pctReadTagged = (@readTaggedItems.to_f/tagged)*100 pctReadUntagged = (@readUntaggedItems.to_f/untagged)*100 puts '==============================' puts ' General Stats ' puts '------------------------------' puts sprintf "%-15s %2d (%2d%% read)", 'Tagged items:', tagged, pctReadTagged puts sprintf "%-15s %2d (%2d%% read)", 'Untagged items:', untagged, pctReadUntagged puts '------------------------------' end |