Class: Cleanweb

Inherits:
Object
  • Object
show all
Includes:
Spam, Version
Defined in:
lib/cleanweb.rb

Defined Under Namespace

Modules: Spam, Version Classes: KeyError, NoBodyError, NoSubjectError

Constant Summary collapse

SPAM_URL =
"http://cleanweb-api.yandex.ru/1.0/check-spam"
@@api_key =
nil

Constants included from Version

Version::VERSION

Class Attribute Summary collapse

Instance Method Summary collapse

Methods included from Spam

#ask_yandex, #parse_xml, #spam?, #spam_params

Constructor Details

#initialize(params) ⇒ Cleanweb

Returns a new instance of Cleanweb.



29
30
31
32
33
# File 'lib/cleanweb.rb', line 29

def initialize params
  check_key
  @params = params
  check_params
end

Class Attribute Details

.api_keyObject

Returns the value of attribute api_key.



21
22
23
# File 'lib/cleanweb.rb', line 21

def api_key
  @api_key
end

Instance Method Details

#check_bodyObject

Raises:



49
50
51
52
# File 'lib/cleanweb.rb', line 49

def check_body
  @body = @params[:body]
  raise NoBodyError if @body.nil?
end

#check_keyObject

Raises:



35
36
37
# File 'lib/cleanweb.rb', line 35

def check_key
  raise KeyError if @@api_key.nil?
end

#check_paramsObject



39
40
41
42
# File 'lib/cleanweb.rb', line 39

def check_params
  check_subject
  check_body
end

#check_subjectObject

Raises:



44
45
46
47
# File 'lib/cleanweb.rb', line 44

def check_subject
  @subject = @params[:subject]
  raise NoSubjectError if @subject.nil?
end