Class: Converse::MysqlConversation
- Inherits:
-
Conversation
- Object
- Conversation
- Converse::MysqlConversation
- Defined in:
- lib/converse/comms/mysql/mysql_conversation.rb
Instance Attribute Summary collapse
-
#database ⇒ Object
writeonly
Sets the attribute database.
-
#password ⇒ Object
writeonly
Sets the attribute password.
-
#query ⇒ Object
Returns the value of attribute query.
-
#username ⇒ Object
writeonly
Sets the attribute username.
Attributes inherited from Conversation
#body, #connection, #headers, #host, #path, #port, #request, #response, #subscribers, #uri
Instance Method Summary collapse
- #ask ⇒ Object
- #connect ⇒ Object
- #converse ⇒ Object
-
#initialize(uri) ⇒ MysqlConversation
constructor
A new instance of MysqlConversation.
- #say ⇒ Object
Methods inherited from Conversation
#notify_subscribers, #subscribe
Constructor Details
#initialize(uri) ⇒ MysqlConversation
Returns a new instance of MysqlConversation.
11 12 13 14 15 16 17 |
# File 'lib/converse/comms/mysql/mysql_conversation.rb', line 11 def initialize(uri) super(uri) parsed = URI.parse(uri) @username = parsed.user @password = parsed.password @database = parsed.path.gsub(/\//, "") end |
Instance Attribute Details
#database=(value) ⇒ Object (writeonly)
Sets the attribute database
8 9 10 |
# File 'lib/converse/comms/mysql/mysql_conversation.rb', line 8 def database=(value) @database = value end |
#password=(value) ⇒ Object (writeonly)
Sets the attribute password
7 8 9 |
# File 'lib/converse/comms/mysql/mysql_conversation.rb', line 7 def password=(value) @password = value end |
#query ⇒ Object
Returns the value of attribute query.
9 10 11 |
# File 'lib/converse/comms/mysql/mysql_conversation.rb', line 9 def query @query end |
#username=(value) ⇒ Object (writeonly)
Sets the attribute username
6 7 8 |
# File 'lib/converse/comms/mysql/mysql_conversation.rb', line 6 def username=(value) @username = value end |
Instance Method Details
#ask ⇒ Object
32 33 34 |
# File 'lib/converse/comms/mysql/mysql_conversation.rb', line 32 def ask converse end |
#connect ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/converse/comms/mysql/mysql_conversation.rb', line 19 def connect() @client = Mysql2::Client.new(:host => @host, :port => @port.to_f, :username => @username, :password => @password, :database => @database) end |
#converse ⇒ Object
27 28 29 30 |
# File 'lib/converse/comms/mysql/mysql_conversation.rb', line 27 def converse connect() @client.query(@query) end |
#say ⇒ Object
36 37 38 |
# File 'lib/converse/comms/mysql/mysql_conversation.rb', line 36 def say converse end |