Class: LingotekClient::Resource::Workflow

Inherits:
Base
  • Object
show all
Defined in:
lib/lingotek-client/resource/workflow.rb

Constant Summary

Constants inherited from Base

Base::ERRORS, Base::FAIL, Base::RESULTS

Instance Attribute Summary collapse

Attributes inherited from Base

#data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

all, key

Constructor Details

#initialize(attrs) ⇒ Workflow

Returns a new instance of Workflow.



6
7
8
9
10
11
12
13
# File 'lib/lingotek-client/resource/workflow.rb', line 6

def initialize(attrs)
  super(attrs)
  @id = attrs['id']
  @name = attrs['name']
  @desc = attrs['desc']
  @mod = attrs['mod']
  @steps = attrs['steps']
end

Instance Attribute Details

#descObject

Returns the value of attribute desc.



4
5
6
# File 'lib/lingotek-client/resource/workflow.rb', line 4

def desc
  @desc
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/lingotek-client/resource/workflow.rb', line 4

def id
  @id
end

#modObject

Returns the value of attribute mod.



4
5
6
# File 'lib/lingotek-client/resource/workflow.rb', line 4

def mod
  @mod
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/lingotek-client/resource/workflow.rb', line 4

def name
  @name
end

#stepsObject

Returns the value of attribute steps.



4
5
6
# File 'lib/lingotek-client/resource/workflow.rb', line 4

def steps
  @steps
end

Class Method Details

.find(id) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/lingotek-client/resource/workflow.rb', line 15

def self.find(id)
  action_name = key
  object = JSON.parse(Lingotek::API::api.send("get#{action_name}", "id" => id))
  raise Exception.new "API call failed" if object[Lingotek::API::Base::RESULTS] == Lingotek::API::Base::FAIL
  object = self.new object[action_name.downcase]
  raise Exception.new "#{Key} not found" if object.id == nil
  object
end