Class: Transloadit
- Inherits:
-
Object
- Object
- Transloadit
- Defined in:
- lib/transloadit.rb,
lib/transloadit/version.rb
Overview
Implements the Transloadit REST API in Ruby. Check the README for usage instructions.
Defined Under Namespace
Classes: Assembly, Request, Response, Step
Constant Summary collapse
- VERSION =
'1.2.0'
Instance Attribute Summary collapse
-
#duration ⇒ Integer
The duration in seconds that signed API requests generated from this instance remain valid.
-
#key ⇒ String
Your Transloadit auth key.
-
#max_size ⇒ Object
Returns the value of attribute max_size.
-
#secret ⇒ String
Your Transloadit auth secret, for signing requests.
Instance Method Summary collapse
-
#assembly(options = {}) ⇒ Object
Creates a Transloadit::Assembly ready to be sent to the REST API.
-
#initialize(options = {}) ⇒ Transloadit
constructor
Creates a new instance of the Transloadit API.
-
#inspect ⇒ String
A human-readable version of the Transloadit.
-
#step(name, robot, options = {}) ⇒ Step
Creates a Transloadit::Step describing a step in an upload assembly.
-
#to_hash ⇒ Hash
A Transloadit-compatible Hash of the instance’s contents.
-
#to_json ⇒ String
JSON-encoded String containing the object’s hash contents.
Constructor Details
#initialize(options = {}) ⇒ Transloadit
Creates a new instance of the Transloadit API.
37 38 39 40 41 42 43 44 |
# File 'lib/transloadit.rb', line 37 def initialize( = {}) self.key = [:key] self.secret = [:secret] self.duration = [:duration] || 5 * 60 self.max_size = [:max_size] _ensure_key_provided end |
Instance Attribute Details
#duration ⇒ Integer
Returns the duration in seconds that signed API requests generated from this instance remain valid.
22 23 24 |
# File 'lib/transloadit.rb', line 22 def duration @duration end |
#key ⇒ String
Returns your Transloadit auth key.
15 16 17 |
# File 'lib/transloadit.rb', line 15 def key @key end |
#max_size ⇒ Object
Returns the value of attribute max_size.
24 25 26 |
# File 'lib/transloadit.rb', line 24 def max_size @max_size end |
#secret ⇒ String
Returns your Transloadit auth secret, for signing requests.
18 19 20 |
# File 'lib/transloadit.rb', line 18 def secret @secret end |
Instance Method Details
#assembly(options = {}) ⇒ Object
Creates a Transloadit::Assembly ready to be sent to the REST API.
74 75 76 |
# File 'lib/transloadit.rb', line 74 def assembly( = {}) Transloadit::Assembly.new(self, ) end |
#inspect ⇒ String
Returns a human-readable version of the Transloadit.
81 82 83 |
# File 'lib/transloadit.rb', line 81 def inspect self.to_hash.inspect end |
#step(name, robot, options = {}) ⇒ Step
Creates a Transloadit::Step describing a step in an upload assembly.
56 57 58 |
# File 'lib/transloadit.rb', line 56 def step(name, robot, = {}) Transloadit::Step.new(name, robot, ) end |
#to_hash ⇒ Hash
Returns a Transloadit-compatible Hash of the instance’s contents.
88 89 90 91 92 93 |
# File 'lib/transloadit.rb', line 88 def to_hash result = { :key => self.key } result.update(:max_size => self.max_size) unless self.max_size.nil? result.update(:expires => _generate_expiry) unless self.secret.nil? result end |
#to_json ⇒ String
Returns JSON-encoded String containing the object’s hash contents.
98 99 100 |
# File 'lib/transloadit.rb', line 98 def to_json MultiJson.dump(self.to_hash) end |