Class: Ecoportal::API::V2::S3::Files::Poll

Inherits:
Common::Content::DoubleModel show all
Defined in:
lib/ecoportal/api/v2/s3/files/poll.rb

Constant Summary

Constants included from Common::Content::DoubleModel::Diffable

Common::Content::DoubleModel::Diffable::DIFF_CLASS

Constants included from Common::Content::DoubleModel::Base

Common::Content::DoubleModel::Base::NOT_USED

Instance Attribute Summary

Attributes included from Common::Content::DoubleModel::Parented

#_parent, #_parent_key

Instance Method Summary collapse

Methods inherited from Common::Content::DoubleModel

#initialize, new_uuid

Methods included from Common::Content::DoubleModel::Diffable

#as_update, #dirty?

Methods included from Common::Content::Includer

#include_missing

Constructor Details

This class inherits a constructor from Ecoportal::API::Common::Content::DoubleModel

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/ecoportal/api/v2/s3/files/poll.rb', line 49

def complete?
  status&.complete?
end

#container_idObject

The final File eP container id



19
20
21
22
23
# File 'lib/ecoportal/api/v2/s3/files/poll.rb', line 19

def container_id
  return unless status?

  status.container_id
end

#failed?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/ecoportal/api/v2/s3/files/poll.rb', line 57

def failed?
  status&.failed?
end

#pending?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/ecoportal/api/v2/s3/files/poll.rb', line 45

def pending?
  !complete?
end

#poll_idObject Also known as: id



10
11
12
13
14
15
# File 'lib/ecoportal/api/v2/s3/files/poll.rb', line 10

def poll_id
  return @poll_id       if instance_variable_defined?(:@poll_id)
  return @poll_id = nil unless (uri = parsed_poll_url)

  @poll_id = uri.path.split('/poll/').last
end

#status=(value) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ecoportal/api/v2/s3/files/poll.rb', line 29

def status=(value)
  case value
  when NilClass
    doc['status'] = nil
  when Ecoportal::API::V2::S3::Files::PollStatus
    doc['status'] = JSON.parse(value.to_json)
  when Hash
    doc['status'] = value
  else
    # TODO

    raise "Invalid set on status: Need nil, PollStatus or Hash; got #{value.class}"
  end

  remove_instance_variable('@status') if defined?(@status)
end

#status?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/ecoportal/api/v2/s3/files/poll.rb', line 25

def status?
  !doc['status'].nil?
end

#success?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/ecoportal/api/v2/s3/files/poll.rb', line 53

def success?
  status&.success?
end

#timeout?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/ecoportal/api/v2/s3/files/poll.rb', line 61

def timeout?
  status&.timeout?
end