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.
12 13 14 |
# File 'lib/git_fit/util/tally.rb', line 12 def initialize(count = 0) @value = count end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
10 11 12 |
# File 'lib/git_fit/util/tally.rb', line 10 def value @value end |
Instance Method Details
#<(other) ⇒ Object
38 39 40 |
# File 'lib/git_fit/util/tally.rb', line 38 def <(other) to_i < other.to_i end |
#==(other) ⇒ Object
34 35 36 |
# File 'lib/git_fit/util/tally.rb', line 34 def ==(other) to_i == other.to_i end |
#add(n = 1) ⇒ Object
16 17 18 19 |
# File 'lib/git_fit/util/tally.rb', line 16 def add(n = 1) @value += n self end |
#inspect ⇒ Object
51 52 53 |
# File 'lib/git_fit/util/tally.rb', line 51 def inspect "#<#{self.class.name} value=#{@value}>" end |
#reset(count = 0) ⇒ Object
21 22 23 24 |
# File 'lib/git_fit/util/tally.rb', line 21 def reset(count = 0) @value = count self end |
#to_i ⇒ Object
26 27 28 |
# File 'lib/git_fit/util/tally.rb', line 26 def to_i @value.to_i end |
#to_int ⇒ Object
30 31 32 |
# File 'lib/git_fit/util/tally.rb', line 30 def to_int to_i end |
#to_s(format: :chinese) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/git_fit/util/tally.rb', line 42 def to_s(format: :chinese) case format when :arabic then @value.to_s else to_chinese end rescue StandardError @value.to_s end |