Class: SyoboiCalendar::Response

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/syoboi_calendar/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(faraday_response:, response_parser_class:) ⇒ Response

Returns a new instance of Response.

Parameters:

  • faraday_response (Faraday::Response)
  • response_parser_class (Class)


7
8
9
10
# File 'lib/syoboi_calendar/response.rb', line 7

def initialize(faraday_response:, response_parser_class:)
  @faraday_response = faraday_response
  @response_parser_class = response_parser_class
end

Instance Method Details

#bodyString

Returns:

  • (String)


13
14
15
# File 'lib/syoboi_calendar/response.rb', line 13

def body
  faraday_response.body
end

#each(&block) ⇒ Object

Note:

Implementation for Enumerable



18
19
20
# File 'lib/syoboi_calendar/response.rb', line 18

def each(&block)
  resources.each(&block)
end

#headersHash

Returns:

  • (Hash)


23
24
25
# File 'lib/syoboi_calendar/response.rb', line 23

def headers
  faraday_response.headers
end

#resourcesArray<SyoboiCalendar::Resources::BaseResource>



28
29
30
# File 'lib/syoboi_calendar/response.rb', line 28

def resources
  @resources ||= response_parser_class.new(body).parse
end

#statusInteger

Returns:

  • (Integer)


33
34
35
# File 'lib/syoboi_calendar/response.rb', line 33

def status
  faraday_response.status
end