Class: Trifle::Stats::Designator::Linear
- Inherits:
-
Object
- Object
- Trifle::Stats::Designator::Linear
- Defined in:
- lib/trifle/stats/designator/linear.rb
Instance Attribute Summary collapse
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
-
#step ⇒ Object
readonly
Returns the value of attribute step.
Instance Method Summary collapse
-
#designate(value:) ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#initialize(min:, max:, step:) ⇒ Linear
constructor
A new instance of Linear.
Constructor Details
#initialize(min:, max:, step:) ⇒ Linear
Returns a new instance of Linear.
9 10 11 12 13 |
# File 'lib/trifle/stats/designator/linear.rb', line 9 def initialize(min:, max:, step:) @min = min @max = max @step = step.to_i end |
Instance Attribute Details
#max ⇒ Object (readonly)
Returns the value of attribute max.
7 8 9 |
# File 'lib/trifle/stats/designator/linear.rb', line 7 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
7 8 9 |
# File 'lib/trifle/stats/designator/linear.rb', line 7 def min @min end |
#step ⇒ Object (readonly)
Returns the value of attribute step.
7 8 9 |
# File 'lib/trifle/stats/designator/linear.rb', line 7 def step @step end |
Instance Method Details
#designate(value:) ⇒ Object
rubocop:disable Metrics/AbcSize
15 16 17 18 19 20 |
# File 'lib/trifle/stats/designator/linear.rb', line 15 def designate(value:) # rubocop:disable Metrics/AbcSize return min.to_s if value <= min return "#{max}+" if value > max (value.ceil / step * step + ((value.ceil % step).zero? ? 0 : step)).to_s end |