Sha256: 3ffd9f9af79a56bb2baed92a20fd151f9a293ff6fa8d0c0eae88c584f0e21e38

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'json'

module Mulder
  class Instance

    attr_reader :fog_compute_instance

    def initialize(fog_compute_instance)
      @fog_compute_instance = fog_compute_instance
    end

    def id
      @fog_compute_instance.id
    end

    def dns_name
      @fog_compute_instance.dns_name
    end

    def public_ip_address
      @fog_compute_instance.public_ip_address
    end

    def private_ip_address
      @fog_compute_instance.private_ip_address
    end

    def availability_zone
      @fog_compute_instance.availability_zone
    end

    def vpc_id
      @fog_compute_instance.vpc_id
    end

    def created_at
      @fog_compute_instance.created_at
    end

    def exists?
      !@fog_compute_instance.nil?
    end

    def as_hash
      @as_hash ||= {
        id: id,
        dns_name: dns_name,
        public_ip_address: public_ip_address,
        private_ip_address: private_ip_address,
        availability_zone: availability_zone,
        vpc_id: vpc_id,
        created_at: created_at
      }.delete_if { |_, value| value == '' || value == nil }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mulder-0.4.0 lib/mulder/instance.rb