Class: TypeBalancer::PositionCalculator::PositionBatch
- Inherits:
-
Object
- Object
- TypeBalancer::PositionCalculator::PositionBatch
- Defined in:
- lib/type_balancer/calculator.rb
Overview
Represents a batch of position calculations
Instance Attribute Summary collapse
-
#available_items ⇒ Object
readonly
Returns the value of attribute available_items.
-
#ratio ⇒ Object
readonly
Returns the value of attribute ratio.
-
#total_count ⇒ Object
readonly
Returns the value of attribute total_count.
Instance Method Summary collapse
-
#initialize(total_count:, ratio:, available_items: nil) ⇒ PositionBatch
constructor
A new instance of PositionBatch.
- #target_count ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(total_count:, ratio:, available_items: nil) ⇒ PositionBatch
Returns a new instance of PositionBatch.
14 15 16 17 18 |
# File 'lib/type_balancer/calculator.rb', line 14 def initialize(total_count:, ratio:, available_items: nil) @total_count = total_count @ratio = ratio @available_items = available_items end |
Instance Attribute Details
#available_items ⇒ Object (readonly)
Returns the value of attribute available_items.
12 13 14 |
# File 'lib/type_balancer/calculator.rb', line 12 def available_items @available_items end |
#ratio ⇒ Object (readonly)
Returns the value of attribute ratio.
12 13 14 |
# File 'lib/type_balancer/calculator.rb', line 12 def ratio @ratio end |
#total_count ⇒ Object (readonly)
Returns the value of attribute total_count.
12 13 14 |
# File 'lib/type_balancer/calculator.rb', line 12 def total_count @total_count end |
Instance Method Details
#target_count ⇒ Object
24 25 26 |
# File 'lib/type_balancer/calculator.rb', line 24 def target_count @target_count ||= (total_count * ratio).round end |
#valid? ⇒ Boolean
20 21 22 |
# File 'lib/type_balancer/calculator.rb', line 20 def valid? valid_basic_inputs? && valid_available_items? end |