Class: CloudscrapeClient::Validate

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudscrape_client/validate.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response:) ⇒ Validate

Returns a new instance of Validate.



3
4
5
# File 'lib/cloudscrape_client/validate.rb', line 3

def initialize(response:)
  @response = response
end

Class Method Details

.to_procObject



7
8
9
# File 'lib/cloudscrape_client/validate.rb', line 7

def self.to_proc
  ->(response) { with(response) }
end

.with(response) ⇒ Object



11
12
13
# File 'lib/cloudscrape_client/validate.rb', line 11

def self.with(response)
  new(response: response).validate
end

Instance Method Details

#validateObject



15
16
17
18
19
20
# File 'lib/cloudscrape_client/validate.rb', line 15

def validate
  fail CloudscrapeClient::InternalServerError, message if internal_error?
  fail CloudscrapeClient::NotFound, message if not_found?

  true
end