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 inherited from Common::Content::DoubleModel

Common::Content::DoubleModel::NOT_USED

Constants included from Common::Content::ClassHelpers

Common::Content::ClassHelpers::NOT_USED

Instance Attribute Summary

Attributes inherited from Common::Content::DoubleModel

#_key, #_parent, #_read_only

Instance Method Summary collapse

Methods inherited from Common::Content::DoubleModel

#_doc_key, #as_json, #as_update, #consolidate!, #dirty?, #doc, embeds_many, embeds_one, enforce!, #initialize, #key, #key=, key?, new_uuid, #original_doc, pass_reader, pass_writer, passarray, passboolean, passdate, passforced, passkey, passthrough, #print_pretty, read_only!, read_only?, #read_only?, #replace_doc, #reset!, #resolved_doc_key, #root, #to_json

Methods included from Common::Content::ClassHelpers

#inheritable_attrs, #inheritable_class_vars, #inherited, #instance_variable_name, #new_class, #resolve_class, #to_constant, #to_time, #uid, #used_param?

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