Class: Mycmd::Client
- Inherits:
-
Object
- Object
- Mycmd::Client
- Defined in:
- lib/mycmd/client.rb
Class Method Summary collapse
Instance Method Summary collapse
- #execute_task(task) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #print(header = true) ⇒ Object
- #query(sql) ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
5 6 7 8 |
# File 'lib/mycmd/client.rb', line 5 def initialize @configuration = Configuration.new @connection = @configuration.connect end |
Class Method Details
.method_missing(action, *args) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/mycmd/client.rb', line 25 def method_missing(action, *args) client = self.new if client.respond_to? action client.send(action, *args) else super end end |
Instance Method Details
#execute_task(task) ⇒ Object
15 16 17 18 |
# File 'lib/mycmd/client.rb', line 15 def execute_task(task) @result = @connection.query(@configuration.tasks[task.to_s]) self end |
#print(header = true) ⇒ Object
20 21 22 |
# File 'lib/mycmd/client.rb', line 20 def print(header=true) Printer.new(@result, header).print end |
#query(sql) ⇒ Object
10 11 12 13 |
# File 'lib/mycmd/client.rb', line 10 def query(sql) @result = @connection.query(sql) self end |