Class: Upload::Response::Success

Inherits:
Base
  • Object
show all
Defined in:
lib/upload/response/success.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#response

Instance Method Summary collapse

Constructor Details

#initialize(response, opts = {}) ⇒ Success

Returns a new instance of Success.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/upload/response/success.rb', line 6

def initialize(response, opts={})
  super(response, opts)

  # Use thumb url instead of the original one
  # The thumb url has fixed width for now (500px)
  # Will be configuarable soon.
  # TODO:
  #   - Check the data field before return
  #   - Allow user to config the size of thumb
  #
  @url = @response["data"]["thumb_url"]

  # carefully check the data key here
  # TODO: add condition to check if there is data key
  #
  @original_url = @response["data"]["img_url"]
end

Instance Attribute Details

#original_urlObject (readonly)

Returns the value of attribute original_url.



4
5
6
# File 'lib/upload/response/success.rb', line 4

def original_url
  @original_url
end

#urlObject (readonly)

Returns the value of attribute url.



4
5
6
# File 'lib/upload/response/success.rb', line 4

def url
  @url
end