Class: Statistic
- Inherits:
-
Object
- Object
- Statistic
- Defined in:
- lib/terrimporter/statistic.rb
Instance Attribute Summary collapse
-
#statistics ⇒ Object
Returns the value of attribute statistics.
-
#times ⇒ Object
Returns the value of attribute times.
Instance Method Summary collapse
- #add(type) ⇒ Object
- #add_message(type, message) ⇒ Object
- #init_data(type) ⇒ Object
-
#initialize ⇒ Statistic
constructor
A new instance of Statistic.
- #print_summary ⇒ Object
Constructor Details
#initialize ⇒ Statistic
Returns a new instance of Statistic.
4 5 6 7 |
# File 'lib/terrimporter/statistic.rb', line 4 def initialize @header = ["---SUMMARY Date: #{Time.now.strftime("%d.%m.%Y %H:%M:%S")}" ] self.statistics = {} end |
Instance Attribute Details
#statistics ⇒ Object
Returns the value of attribute statistics.
2 3 4 |
# File 'lib/terrimporter/statistic.rb', line 2 def statistics @statistics end |
#times ⇒ Object
Returns the value of attribute times.
2 3 4 |
# File 'lib/terrimporter/statistic.rb', line 2 def times @times end |
Instance Method Details
#add(type) ⇒ Object
14 15 16 17 |
# File 'lib/terrimporter/statistic.rb', line 14 def add(type) init_data(type) self.statistics[type][:count] += 1 end |
#add_message(type, message) ⇒ Object
9 10 11 12 |
# File 'lib/terrimporter/statistic.rb', line 9 def (type, ) init_data(type) self.statistics[type][:message] = end |
#init_data(type) ⇒ Object
19 20 21 |
# File 'lib/terrimporter/statistic.rb', line 19 def init_data(type) self.statistics[type] = {:count => 0, :message => ""} if self.statistics[type].nil? end |
#print_summary ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/terrimporter/statistic.rb', line 23 def print_summary @header.each do |h| puts h end self.statistics.each do |key, value| puts "* %3s : %s" % [value[:count], value[:message]] unless value[:count] == 0 end end |