Sha256: c002462da4369d9ef9ae4d98c8749ea75eff08acce3a6dca6f95a87edc9b408c

Contents?: true

Size: 859 Bytes

Versions: 1

Compression:

Stored size: 859 Bytes

Contents

require "comms/conversation"
require "mysql2"

module Converse
  class MysqlConversation < Conversation
    attr_writer :username
    attr_writer :password
    attr_writer :database
    attr_accessor :query

    def initialize(uri)
      super(uri)
      parsed = URI.parse(uri)
      @username = parsed.user
      @password = parsed.password
      @database = parsed.path.gsub(/\//, "")
    end

    def connect()
      @client = Mysql2::Client.new(:host => @host,
                                   :port => @port.to_f,
                                   :username => @username,
                                   :password => @password,
                                   :database => @database)
    end

    def converse
      connect()
      @client.query(@query)
    end

    def ask
      converse
    end

    def say
      converse
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
converse-1.0.4 lib/converse/comms/mysql/mysql_conversation.rb