Class: Oshpark::Upload

Inherits:
Object
  • Object
show all
Includes:
Model, RemoteModel, Stateful
Defined in:
lib/oshpark/upload.rb

Constant Summary collapse

STATES =
%w| WAITING RUNNING SUCCESS ERROR FAILED |

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Stateful

included

Methods included from RemoteModel

#destroy!, included, #reload!, #save!

Methods included from Model

#dirty?, included, #initialize

Class Method Details

.attrsObject



3
4
5
# File 'lib/oshpark/upload.rb', line 3

def self.attrs
  %w| id state original_filename error_message queued_at started_at completed_at errored_at failed_at project_id |
end

.create(file) ⇒ Object



13
14
15
# File 'lib/oshpark/upload.rb', line 13

def self.create file
  self.from_json(Oshpark::client.create_upload(file)['upload'])
end

Instance Method Details

#completed_atObject



37
38
39
# File 'lib/oshpark/upload.rb', line 37

def completed_at
  time_from @completed_at
end

#errored_atObject



41
42
43
# File 'lib/oshpark/upload.rb', line 41

def errored_at
  time_from @errored_at
end

#failed_atObject



45
46
47
# File 'lib/oshpark/upload.rb', line 45

def failed_at
  time_from @failed_at
end

#finished?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/oshpark/upload.rb', line 25

def finished?
  success? || error? || failed?
end

#processing?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/oshpark/upload.rb', line 21

def processing?
  waiting? || running?
end

#projectObject



17
18
19
# File 'lib/oshpark/upload.rb', line 17

def project
  Project.find project_id
end

#queued_atObject



29
30
31
# File 'lib/oshpark/upload.rb', line 29

def queued_at
  time_from @queued_at
end

#started_atObject



33
34
35
# File 'lib/oshpark/upload.rb', line 33

def started_at
  time_from @started_at
end