Class: SI::CopyscapeResponse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_response:) ⇒ CopyscapeResponse

Returns a new instance of CopyscapeResponse.



6
7
8
9
# File 'lib/copyscape_response.rb', line 6

def initialize raw_response:
  @raw_response ||= raw_response
  @error = _error_msg
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



4
5
6
# File 'lib/copyscape_response.rb', line 4

def error
  @error
end

#raw_responseObject (readonly)

Returns the value of attribute raw_response.



4
5
6
# File 'lib/copyscape_response.rb', line 4

def raw_response
  @raw_response
end

Instance Method Details

#query_wordsObject



32
33
34
# File 'lib/copyscape_response.rb', line 32

def query_words
  response['querywords'].to_i if response.is_a?(Hash)
end

#raw_hashObject



15
16
17
# File 'lib/copyscape_response.rb', line 15

def raw_hash
  _to_hash
end

#raw_xmlObject



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

def raw_xml
  raw_response.body
end

#remainingObject



19
20
21
# File 'lib/copyscape_response.rb', line 19

def remaining
  raw_hash['remaining']
end

#responseObject



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

def response
  raw_hash['response']
end

#resultsObject



27
28
29
30
# File 'lib/copyscape_response.rb', line 27

def results
  result = response['result'] if response.is_a?(Hash)
  result.is_a?(Array) ? result : [result].compact
end