Class: Yapi::MAService
- Inherits:
-
Object
- Object
- Yapi::MAService
- Defined in:
- lib/yapi/ma_service.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
- #configure(options = {}) ⇒ Object
-
#initialize(api_key) ⇒ MAService
constructor
A new instance of MAService.
- #parse(sentence) ⇒ Object
Constructor Details
#initialize(api_key) ⇒ MAService
Returns a new instance of MAService.
9 10 11 12 |
# File 'lib/yapi/ma_service.rb', line 9 def initialize(api_key) @client = Client.new(api_key) self.config = {} end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
7 8 9 |
# File 'lib/yapi/ma_service.rb', line 7 def config @config end |
Instance Method Details
#configure(options = {}) ⇒ Object
14 15 16 17 18 |
# File 'lib/yapi/ma_service.rb', line 14 def configure( = {}) .each do |key, value| self.config[key] = value end end |
#parse(sentence) ⇒ Object
20 21 22 23 |
# File 'lib/yapi/ma_service.rb', line 20 def parse sentence req_url = "http://jlp.yahooapis.jp/MAService/V1/parse?appid=#{@client.get_api_key}#{@client.build_url(self.config)}&sentence=#{sentence}" return @client.xml_to_json(open(URI.encode(req_url)).read)[:ResultSet] end |