Class: Dev2func::Stream

Inherits:
Object
  • Object
show all
Defined in:
lib/dev2func/models/stream.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#content_detailObject

Returns the value of attribute content_detail.



3
4
5
# File 'lib/dev2func/models/stream.rb', line 3

def content_detail
  @content_detail
end

#content_typeObject

Returns the value of attribute content_type.



3
4
5
# File 'lib/dev2func/models/stream.rb', line 3

def content_type
  @content_type
end

#error_codeObject

Returns the value of attribute error_code.



3
4
5
# File 'lib/dev2func/models/stream.rb', line 3

def error_code
  @error_code
end

Class Method Details

.parse(content) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/dev2func/models/stream.rb', line 7

def self.parse(content)
  # {"Content-Type"=>"text/html; charset=UTF-8", "Content-Length"=>"103534"}
  Rails.logger.info "[Dev2func] #{content}"
  Rails.logger.info "[Dev2func] #{content[0]}"
  # print(content[0].to_i)
  # print("1) #{Rack::Utils::HTTP_STATUS_CODES["200"].to_i}")
  # print("2) #{Rack::Utils::HTTP_STATUS_CODES["200"]}")
  # print(content[0].to_i != Rack::Utils::HTTP_STATUS_CODES["200"].to_i)
  if content[0].to_i != 200
    Rails.logger.info "[Dev2func] Preparing ingredients"
    error_code = content[0]
    content_type = content[1]
    content_detail = JSON.parse(content[2].first)
  else
    return
  end
end