Class: LingotekClient::Resource::Project
- Defined in:
- lib/lingotek-client/resource/project.rb
Constant Summary collapse
- FILENAME =
'download.zip'
- ACTIVE =
'Active'
- COMPLETED =
'Completed'
Constants inherited from Base
Base::ERRORS, Base::FAIL, Base::RESULTS
Instance Attribute Summary collapse
-
#company_id ⇒ Object
Returns the value of attribute company_id.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#document_ids ⇒ Object
Returns the value of attribute document_ids.
-
#due_date ⇒ Object
Returns the value of attribute due_date.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#percent_complete ⇒ Object
Returns the value of attribute percent_complete.
-
#state ⇒ Object
Returns the value of attribute state.
-
#workflow_id ⇒ Object
Returns the value of attribute workflow_id.
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #active? ⇒ Boolean
- #completed? ⇒ Boolean
- #documents ⇒ Object
-
#initialize(attrs) ⇒ Project
constructor
A new instance of Project.
- #workflow ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(attrs) ⇒ Project
Returns a new instance of Project.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/lingotek-client/resource/project.rb', line 11 def initialize(attrs) super(attrs) @id = attrs['id'] @name = attrs['name'] @state = attrs['state'] @company_id = attrs['companyId'] @percent_complete = attrs['percentComplete'] @document_ids = attrs['documents'].map { |doc| doc['id'] } @created_at = attrs['createdDate'] @workflow_id = attrs['workflowId'] @due_date = attrs['due_date'] end |
Instance Attribute Details
#company_id ⇒ Object
Returns the value of attribute company_id.
4 5 6 |
# File 'lib/lingotek-client/resource/project.rb', line 4 def company_id @company_id end |
#created_at ⇒ Object
Returns the value of attribute created_at.
4 5 6 |
# File 'lib/lingotek-client/resource/project.rb', line 4 def created_at @created_at end |
#document_ids ⇒ Object
Returns the value of attribute document_ids.
4 5 6 |
# File 'lib/lingotek-client/resource/project.rb', line 4 def document_ids @document_ids end |
#due_date ⇒ Object
Returns the value of attribute due_date.
4 5 6 |
# File 'lib/lingotek-client/resource/project.rb', line 4 def due_date @due_date end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/lingotek-client/resource/project.rb', line 4 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/lingotek-client/resource/project.rb', line 4 def name @name end |
#percent_complete ⇒ Object
Returns the value of attribute percent_complete.
4 5 6 |
# File 'lib/lingotek-client/resource/project.rb', line 4 def percent_complete @percent_complete end |
#state ⇒ Object
Returns the value of attribute state.
4 5 6 |
# File 'lib/lingotek-client/resource/project.rb', line 4 def state @state end |
#workflow_id ⇒ Object
Returns the value of attribute workflow_id.
4 5 6 |
# File 'lib/lingotek-client/resource/project.rb', line 4 def workflow_id @workflow_id end |
Class Method Details
.download_documents(id, target) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/lingotek-client/resource/project.rb', line 32 def self.download_documents(id, target) FileUtils.mkdir_p("#{target}/#{id}") File.open(FILENAME, 'wa') do |f| f.write(Lingotek::API::api.downloadProjectDocuments projectId: id) end end |
Instance Method Details
#active? ⇒ Boolean
39 40 41 |
# File 'lib/lingotek-client/resource/project.rb', line 39 def active? @state == ACTIVE end |
#completed? ⇒ Boolean
43 44 45 |
# File 'lib/lingotek-client/resource/project.rb', line 43 def completed? @state == COMPLETED end |
#documents ⇒ Object
28 29 30 |
# File 'lib/lingotek-client/resource/project.rb', line 28 def documents @document_ids.map { |doc_id| Lingotek::API::Document.find(doc_id) } end |
#workflow ⇒ Object
24 25 26 |
# File 'lib/lingotek-client/resource/project.rb', line 24 def workflow @workflow ||= Lingotek::API::Workflow.find @workflow_id if @workflow_id && @workflow_id != 0 end |