Class: Mocodo::Dialogue
Constant Summary collapse
- EndPoint =
"/dialogue/v1/dialogue"
Constants inherited from Base
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Attributes inherited from Base
Instance Method Summary collapse
- #configure(options = {}) ⇒ Object
- #create_dialogue(talk) ⇒ Object
- #get_current_data(option = nil) ⇒ Object
-
#initialize(*args) ⇒ Dialogue
constructor
A new instance of Dialogue.
Constructor Details
#initialize(*args) ⇒ Dialogue
Returns a new instance of Dialogue.
6 7 8 9 |
# File 'lib/mocodo/dialogue.rb', line 6 def initialize(*args) super @config = {} end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/mocodo/dialogue.rb', line 5 def config @config end |
Instance Method Details
#configure(options = {}) ⇒ Object
11 12 13 |
# File 'lib/mocodo/dialogue.rb', line 11 def configure( = {}) @config.merge!() end |
#create_dialogue(talk) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/mocodo/dialogue.rb', line 19 def create_dialogue(talk) response = post(build_url(EndPoint), @config.merge(utt: talk).to_json, {'Content-Type' =>'application/json'}) response = JSON.parse(response, symbolize_names: true) configure(response) return response[:utt] end |
#get_current_data(option = nil) ⇒ Object
15 16 17 |
# File 'lib/mocodo/dialogue.rb', line 15 def get_current_data(option=nil) option.nil? ? @config : @config[option] end |