class Cloudcost::Server

Public Class Methods

new(data) click to toggle source
# File lib/cloudcost/server.rb, line 11
def initialize(data)
  @data = data
  @total_storage_per_type = sum_up_storage_per_type
end

Public Instance Methods

flavor() click to toggle source
# File lib/cloudcost/server.rb, line 24
def flavor
  @data[:flavor][:slug]
end
memory_gb() click to toggle source
# File lib/cloudcost/server.rb, line 32
def memory_gb
  @data[:flavor][:memory_gb]
end
name() click to toggle source
# File lib/cloudcost/server.rb, line 16
def name
  @data[:name]
end
server_costs_per_day() click to toggle source
# File lib/cloudcost/server.rb, line 48
def server_costs_per_day
  Pricing.server_costs_per_day(@data[:flavor][:slug])
end
storage_costs_per_day(type = :ssd) click to toggle source
# File lib/cloudcost/server.rb, line 52
def storage_costs_per_day(type = :ssd)
  Pricing.storage_costs_per_day(type.to_s, storage_size(type))
end
storage_size(type = :ssd) click to toggle source
# File lib/cloudcost/server.rb, line 44
def storage_size(type = :ssd)
  @total_storage_per_type[type] || 0
end
sum_up_storage_per_type() click to toggle source
# File lib/cloudcost/server.rb, line 60
def sum_up_storage_per_type
  sum = {}
  @data[:volumes].group_by { |volume| volume[:type].itself }.each do |group, vols|
    sum.store(group.to_sym, 0)
    vols.each { |volume| sum[volume[:type].to_sym] += volume[:size_gb] }
  end
  sum
end
tags() click to toggle source
# File lib/cloudcost/server.rb, line 36
def tags
  @data[:tags]
end
tags_to_s() click to toggle source
# File lib/cloudcost/server.rb, line 40
def tags_to_s
  Cloudcost.tags_to_s(tags)
end
total_costs_per_day() click to toggle source
# File lib/cloudcost/server.rb, line 56
def total_costs_per_day
  server_costs_per_day + storage_costs_per_day(:ssd) + storage_costs_per_day(:bulk)
end
uuid() click to toggle source
# File lib/cloudcost/server.rb, line 20
def uuid
  @data[:uuid]
end
vcpu_count() click to toggle source
# File lib/cloudcost/server.rb, line 28
def vcpu_count
  @data[:flavor][:vcpu_count]
end