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