Class: DynamoAutoscale::UnitCost
- Inherits:
-
Object
- Object
- DynamoAutoscale::UnitCost
- Defined in:
- lib/dynamo-autoscale/unit_cost.rb
Constant Summary collapse
- HOURLY_PRICING =
Pricing information obtained from: aws.amazon.com/dynamodb/pricing/
{ 'us-east-1' => { read: { dollars: 0.0065, per: 50 }, write: { dollars: 0.0065, per: 10 }, }, 'us-west-1' => { read: { dollars: 0.0065, per: 50 }, write: { dollars: 0.0065, per: 10 }, }, }
Class Method Summary collapse
-
.read(units, opts = {}) ⇒ Object
Returns the cost of N read units for an hour in a given region, which defaults to whatever is in DynamoAutoscale::DEFAULT_AWS_REGION.
-
.write(units, opts = {}) ⇒ Object
Returns the cost of N write units for an hour in a given region, which defaults to whatever is in DynamoAutoscale::DEFAULT_AWS_REGION.
Class Method Details
.read(units, opts = {}) ⇒ Object
Returns the cost of N read units for an hour in a given region, which defaults to whatever is in DynamoAutoscale::DEFAULT_AWS_REGION.
Example:
DynamoAutoscale::UnitCost.read(500, region: 'us-west-1')
#=> 0.065
23 24 25 26 |
# File 'lib/dynamo-autoscale/unit_cost.rb', line 23 def self.read units, opts = {} pricing = HOURLY_PRICING[opts[:region] || DEFAULT_AWS_REGION][:read] ((units / pricing[:per].to_f) * pricing[:dollars]) end |
.write(units, opts = {}) ⇒ Object
Returns the cost of N write units for an hour in a given region, which defaults to whatever is in DynamoAutoscale::DEFAULT_AWS_REGION.
Example:
DynamoAutoscale::UnitCost.write(500, region: 'us-west-1')
#=> 0.325
36 37 38 39 |
# File 'lib/dynamo-autoscale/unit_cost.rb', line 36 def self.write units, opts = {} pricing = HOURLY_PRICING[opts[:region] || DEFAULT_AWS_REGION][:write] ((units / pricing[:per].to_f) * pricing[:dollars]) end |