Class: MotionGiphy::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/motion-giphy/response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data.



17
18
19
# File 'lib/motion-giphy/response.rb', line 17

def data
  @data
end

#errorObject

Returns the value of attribute error.



17
18
19
# File 'lib/motion-giphy/response.rb', line 17

def error
  @error
end

#jsonObject

Returns the value of attribute json.



17
18
19
# File 'lib/motion-giphy/response.rb', line 17

def json
  @json
end

#successObject

Returns the value of attribute success.



17
18
19
# File 'lib/motion-giphy/response.rb', line 17

def success
  @success
end

Class Method Details

.build_with_result(result) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/motion-giphy/response.rb', line 3

def self.build_with_result(result)
  response = self.new

  if result.success?
    response.success = true
    response.json = result.object
  else
    response.success = false
    response.error = MotionGiphy::Error.new(result.error)
  end

  response
end

Instance Method Details

#metaObject



31
32
33
# File 'lib/motion-giphy/response.rb', line 31

def meta
  @meta ||= MoptionGiphy::Meta.new(json["meta"])
end

#paginationObject



27
28
29
# File 'lib/motion-giphy/response.rb', line 27

def pagination
  @pages ||= MotionGiphy::Pagination.new(json["pagination"])
end

#process_data_as_batchObject



23
24
25
# File 'lib/motion-giphy/response.rb', line 23

def process_data_as_batch
  self.data = gif.process_batch(self.json["data"])
end

#process_data_as_singularObject



19
20
21
# File 'lib/motion-giphy/response.rb', line 19

def process_data_as_singular
  self.data = gif.new(self.json["data"])
end

#success?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/motion-giphy/response.rb', line 35

def success?
  @success
end