Class: ItemStats

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

Instance Method Summary collapse

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



12
13
14
# File 'lib/itemStats.rb', line 12

def print
  printGeneralStats
end

#printGeneralStatsObject



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