Class: GitFit::Source::Tally

Inherits:
Object
  • Object
show all
Defined in:
lib/git_fit/source/tally.rb

Constant Summary collapse

DIGITS =
%w[          ]

Instance Method Summary collapse

Constructor Details

#initialize(count = 0) ⇒ Tally

Returns a new instance of Tally.



8
9
10
# File 'lib/git_fit/source/tally.rb', line 8

def initialize(count = 0)
  @count = count
end

Instance Method Details

#add(n = 1) ⇒ Object



12
13
14
# File 'lib/git_fit/source/tally.rb', line 12

def add(n = 1)
  @count += n
end

#to_sObject



16
17
18
19
20
21
# File 'lib/git_fit/source/tally.rb', line 16

def to_s
  return @count.to_s if @count > 9999
  chinese_numeral
rescue StandardError
  @count.to_s
end