Class: SI::CopyScape
- Inherits:
-
Object
show all
- Defined in:
- lib/version.rb,
lib/copyscape.rb
Defined Under Namespace
Classes: Balance, Match, PrivateIndex
Constant Summary
collapse
- VERSION =
'0.1.1'
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(username: nil, api_key: nil, uri: nil, match_percent: 5) ⇒ CopyScape
Returns a new instance of CopyScape.
11
12
13
14
15
16
17
|
# File 'lib/copyscape.rb', line 11
def initialize username: nil, api_key: nil, uri: nil, match_percent: 5
username ||= ENV['COPYSCAPE_USERNAME']
api_key ||= ENV['COPYSCAPE_API_KEY']
uri ||= 'http://www.copyscape.com/api/'
@match_percent = match_percent
@api = SI::CopyscapeAPI.new(username: username, api_key: api_key, api_url: uri)
end
|
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
9
10
11
|
# File 'lib/copyscape.rb', line 9
def api
@api
end
|
#match_percent ⇒ Object
Returns the value of attribute match_percent.
9
10
11
|
# File 'lib/copyscape.rb', line 9
def match_percent
@match_percent
end
|
Instance Method Details
#add_to_private_index(text:, title: nil, id: nil, encoding: 'UTF-8') ⇒ Object
52
53
54
55
56
|
# File 'lib/copyscape.rb', line 52
def add_to_private_index text:, title: nil, id: nil, encoding: 'UTF-8'
params = { e: encoding, a: title, i: id }
res = _request(operation: 'pindexadd', params: params, postdata: text).response
PrivateIndex.new(res['words'].to_i, res['handle'], res['id'], res['title'])
end
|
#credit_balance ⇒ Object
23
24
25
26
|
# File 'lib/copyscape.rb', line 23
def credit_balance
res = _request(operation: 'balance').remaining
Balance.new(res['value'].to_f, res['total'].to_i, res['today'].to_i)
end
|
#error ⇒ Object
19
20
21
|
# File 'lib/copyscape.rb', line 19
def error
api.response.error
end
|
#internet_and_private_matches!(text) ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/copyscape.rb', line 44
def internet_and_private_matches! text
return SI::CopyscapeMatches.new(
response: _text_search(text: text, operation: 'cpsearch'),
match_percent: match_percent
)
end
|
#internet_matches!(text) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/copyscape.rb', line 28
def internet_matches! text
return SI::CopyscapeMatches.new(
response: _text_search(text: text, operation: 'csearch'),
match_percent: match_percent
)
end
|
#private_matches!(text) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/copyscape.rb', line 36
def private_matches! text
return SI::CopyscapeMatches.new(
response: _text_search(text: text, operation: 'psearch'),
match_percent: match_percent
)
end
|