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.



6
7
8
# File 'lib/git_fit/source/tally.rb', line 6

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

Instance Method Details

#add(n = 1) ⇒ Object



10
11
12
# File 'lib/git_fit/source/tally.rb', line 10

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

#to_sObject



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

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