Class: SnapshotsBiller

Inherits:
Biller
  • Object
show all
Defined in:
service/billers/snapshots.rb

Overview

Biller for VM Snapshots

Instance Method Summary collapse

Methods inherited from Biller

#billing_period, #costs, #initialize

Constructor Details

This class inherits a constructor from Biller

Instance Method Details

#bill(bill:, state:, delta:, record: nil) ⇒ Object

See Also:



15
16
17
18
# File 'service/billers/snapshots.rb', line 15

def bill bill:, state:, delta:, record: nil
  bill[:snapshots] = delta * @cost * state[:snaps]
  bill
end

#check_billerObject

Checking if Snapshots costs are given, otherwise there is no point to calculate it



4
5
6
7
8
9
10
11
12
# File 'service/billers/snapshots.rb', line 4

def check_biller
  @cost = JSON.parse(costs['SNAPSHOT_COST'])
  return false if @cost.nil?

  @cost = @cost.to_f
  return @cost > 0
rescue
  return false
end