Class: GitFit::Util::Tally
- Inherits:
-
Object
- Object
- GitFit::Util::Tally
- Defined in:
- lib/git_fit/util/tally.rb
Constant Summary collapse
- DIGITS =
%w[零 一 二 三 四 五 六 七 八 九 十].freeze
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #<(other) ⇒ Object
- #==(other) ⇒ Object
- #add(n = 1) ⇒ Object
-
#initialize(count = 0) ⇒ Tally
constructor
A new instance of Tally.
- #inspect ⇒ Object
- #reset(count = 0) ⇒ Object
- #to_i ⇒ Object
- #to_int ⇒ Object
- #to_s(format: :chinese) ⇒ Object
Constructor Details
#initialize(count = 0) ⇒ Tally
Returns a new instance of Tally.
10 11 12 |
# File 'lib/git_fit/util/tally.rb', line 10 def initialize(count = 0) @value = count end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
8 9 10 |
# File 'lib/git_fit/util/tally.rb', line 8 def value @value end |
Instance Method Details
#<(other) ⇒ Object
36 37 38 |
# File 'lib/git_fit/util/tally.rb', line 36 def <(other) to_i < other.to_i end |
#==(other) ⇒ Object
32 33 34 |
# File 'lib/git_fit/util/tally.rb', line 32 def ==(other) to_i == other.to_i end |
#add(n = 1) ⇒ Object
14 15 16 17 |
# File 'lib/git_fit/util/tally.rb', line 14 def add(n = 1) @value += n self end |
#inspect ⇒ Object
49 50 51 |
# File 'lib/git_fit/util/tally.rb', line 49 def inspect "#<#{self.class.name} value=#{@value}>" end |
#reset(count = 0) ⇒ Object
19 20 21 22 |
# File 'lib/git_fit/util/tally.rb', line 19 def reset(count = 0) @value = count self end |
#to_i ⇒ Object
24 25 26 |
# File 'lib/git_fit/util/tally.rb', line 24 def to_i @value.to_i end |
#to_int ⇒ Object
28 29 30 |
# File 'lib/git_fit/util/tally.rb', line 28 def to_int to_i end |
#to_s(format: :chinese) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/git_fit/util/tally.rb', line 40 def to_s(format: :chinese) case format when :arabic then @value.to_s else to_chinese end rescue StandardError @value.to_s end |