Class: AfterTheDeadline
- Inherits:
-
Object
- Object
- AfterTheDeadline
- Defined in:
- lib/merimee/after_the_deadline.rb
Defined Under Namespace
Constant Summary collapse
- BASE_URIS =
{ 'en' => 'http://service.afterthedeadline.com', 'fr' => 'http://fr.service.afterthedeadline.com', 'de' => 'http://de.service.afterthedeadline.com', 'pt' => 'http://pt.service.afterthedeadline.com', 'es' => 'http://es.service.afterthedeadline.com' }
- BASE_URI =
'http://service.afterthedeadline.com'
Class Attribute Summary collapse
-
.key ⇒ Object
Returns the value of attribute key.
-
.language ⇒ Object
Returns the value of attribute language.
Class Method Summary collapse
-
.check(data) ⇒ Object
(also: check_document)
Invoke the checkDocument service with provided text.
-
.metrics(data) ⇒ Object
(also: stats)
Invoke the stats service with provided text.
Class Attribute Details
.key ⇒ Object
Returns the value of attribute key.
16 17 18 |
# File 'lib/merimee/after_the_deadline.rb', line 16 def key @key end |
.language ⇒ Object
Returns the value of attribute language.
16 17 18 |
# File 'lib/merimee/after_the_deadline.rb', line 16 def language @language end |
Class Method Details
.check(data) ⇒ Object Also known as: check_document
Invoke the checkDocument service with provided text.
Returns list of AfterTheDeadline::Error objects.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/merimee/after_the_deadline.rb', line 20 def check(data) results = Crack::XML.parse(perform('/checkDocument', :data => data))['results'] return [] if results.nil? # we have no errors in our data raise "Server returned an error: #{results['message']}" if results['message'] errors = if results['error'].kind_of?(Array) results['error'].map { |e| AfterTheDeadline::Error.new(e) } else [AfterTheDeadline::Error.new(results['error'])] end return errors end |
.metrics(data) ⇒ Object Also known as: stats
Invoke the stats service with provided text.
Returns AfterTheDeadline::Metrics object.
38 39 40 41 42 |
# File 'lib/merimee/after_the_deadline.rb', line 38 def metrics(data) results = Crack::XML.parse(perform('/stats', :data => data))['scores'] return if results.nil? # we have no stats about our data AfterTheDeadline::Metrics.new results['metric'] end |