Class: YanSpeller::Speller
- Inherits:
-
Object
- Object
- YanSpeller::Speller
- Defined in:
- lib/yan_speller/speller.rb
Instance Attribute Summary collapse
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #check_spell(text) ⇒ Object
- #errors_to_s ⇒ Object
-
#initialize ⇒ Speller
constructor
A new instance of Speller.
Constructor Details
#initialize ⇒ Speller
Returns a new instance of Speller.
9 10 11 12 13 |
# File 'lib/yan_speller/speller.rb', line 9 def initialize @spell_request = SpellRequest.new @errors = [] @status = :request_fail end |
Instance Attribute Details
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/yan_speller/speller.rb', line 7 def status @status end |
Instance Method Details
#check_spell(text) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/yan_speller/speller.rb', line 15 def check_spell text result = @spell_request.send text if @spell_request.success? @errors = JSON.parse(result.body).map do |err| SpellError.new err end @status = @errors.empty? ? :no_spell_errors : :spell_errors else @status = :request_fail end end |
#errors_to_s ⇒ Object
27 28 29 |
# File 'lib/yan_speller/speller.rb', line 27 def errors_to_s @errors.map { |err| err.to_s } end |