Sha256: d677fe7f559b8914b34bfbf9cc8738978e272137c56d2515cd138a1ef8c48755

Contents?: true

Size: 871 Bytes

Versions: 11

Compression:

Stored size: 871 Bytes

Contents

module Cloudsponge
  EVENT_TYPES = %w{ INITIALIZING GATHERING SUBMITTING COMPLETE ERROR}
  EVENT_STATUSES = %w{ PENDING INPROGRESS COMPLETED ERROR }
  
  class Event
    attr_accessor :event_type, :status, :value, :description

    def self.from_array(list)
      list.map { |event_data| Event.new(event_data) }.compact
    end

    def inspect
        "\#<#{self.class} #{event_type} #{status} #{value}>"
    end

    def initialize(event_data)
      # is it an error?
      
      # get the basic data
      self.event_type = event_data['event_type']
      self.status = event_data['status']
      self.value = event_data['value']
      self.description = event_data['description']
      self
    end
    
    def is_error?
      self.status == 'ERROR'
    end

    def is_complete?
      self.event_type == 'COMPLETE' && self.status == 'COMPLETED'
    end

  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
cloudsponge-0.10.0 lib/cloudsponge/event.rb
cloudsponge-0.9.13 lib/cloudsponge/event.rb
cloudsponge-0.9.12 lib/cloudsponge/event.rb
cloudsponge-0.9.11 lib/cloudsponge/event.rb
cloudsponge-0.9.10 lib/cloudsponge/event.rb
cloudsponge-0.9.9a lib/cloudsponge/event.rb
cloudsponge-0.9.9 lib/cloudsponge/event.rb
cloudsponge-0.9.8 lib/cloudsponge/event.rb
cloudsponge-0.9.7 cloudsponge/lib/cloudsponge/event.rb
cloudsponge-0.9.6 lib/cloudsponge/event.rb
cloudsponge-0.9.4 lib/cloudsponge/event.rb