Class: SI::CopyscapeMatches

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response:, match_percent:) ⇒ CopyscapeMatches

Returns a new instance of CopyscapeMatches.



7
8
9
10
11
12
# File 'lib/copyscape_matches.rb', line 7

def initialize response:, match_percent:
  @query_word_count = response.query_words.to_i
  @match_percent = match_percent.to_i
  @collection = _build_collection response.results
  @error = response.error
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



5
6
7
# File 'lib/copyscape_matches.rb', line 5

def collection
  @collection
end

#errorObject (readonly)

Returns the value of attribute error.



5
6
7
# File 'lib/copyscape_matches.rb', line 5

def error
  @error
end

#match_percentObject (readonly)

Returns the value of attribute match_percent.



5
6
7
# File 'lib/copyscape_matches.rb', line 5

def match_percent
  @match_percent
end

#query_word_countObject (readonly)

Returns the value of attribute query_word_count.



5
6
7
# File 'lib/copyscape_matches.rb', line 5

def query_word_count
  @query_word_count
end

Instance Method Details

#all_html_snippetsObject



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

def all_html_snippets
  collection.map{|m| m.html_snippet}
end

#all_text_snippetsObject



14
15
16
# File 'lib/copyscape_matches.rb', line 14

def all_text_snippets
  collection.map{|m| m.text_snippet}
end

#each(&block) ⇒ Object



22
23
24
# File 'lib/copyscape_matches.rb', line 22

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