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