Class: Gingerice::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/gingerice/parser.rb

Constant Summary collapse

GINGER_API_ENDPOINT =
'http://services.gingersoftware.com/Ginger/correct/json/GingerTheText'
GINGER_API_VERSION =
'2.0'
GINGER_API_KEY =
'6ae0c3a0-afdc-4532-a810-82ded0054236'
DEFAULT_LANG =
'US'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Parser

Returns a new instance of Parser.



17
18
19
20
21
22
23
24
# File 'lib/gingerice/parser.rb', line 17

def initialize(options = {})
  merge_options(options).each do |key, value|
    send("#{key}=", value)
  end

  @result      = ''
  @corrections = []
end

Instance Attribute Details

#api_endpointObject

Returns the value of attribute api_endpoint.



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

def api_endpoint
  @api_endpoint
end

#api_keyObject

Returns the value of attribute api_key.



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

def api_key
  @api_key
end

#api_versionObject

Returns the value of attribute api_version.



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

def api_version
  @api_version
end

#langObject

Returns the value of attribute lang.



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

def lang
  @lang
end

#raw_responseObject (readonly)

Returns the value of attribute raw_response.



15
16
17
# File 'lib/gingerice/parser.rb', line 15

def raw_response
  @raw_response
end

#resultObject (readonly)

Returns the value of attribute result.



15
16
17
# File 'lib/gingerice/parser.rb', line 15

def result
  @result
end

#textObject (readonly)

Returns the value of attribute text.



15
16
17
# File 'lib/gingerice/parser.rb', line 15

def text
  @text
end

Class Method Details

.default_optionsObject



32
33
34
35
36
37
38
39
# File 'lib/gingerice/parser.rb', line 32

def self.default_options
  {
    :api_endpoint => GINGER_API_ENDPOINT,
    :api_version  => GINGER_API_VERSION,
    :api_key      => GINGER_API_KEY,
    :lang         => DEFAULT_LANG
  }
end

Instance Method Details

#parse(text) ⇒ Object



26
27
28
29
30
# File 'lib/gingerice/parser.rb', line 26

def parse(text)
  @text = text
  perform_request
  process_response
end