Class: Estool::Actions::Cat
- Inherits:
-
Object
- Object
- Estool::Actions::Cat
- Defined in:
- lib/estool/actions/cat.rb
Instance Method Summary collapse
- #cat(action, options, server) ⇒ Object
- #format_options(data) ⇒ Object
-
#initialize(command, options) ⇒ Cat
constructor
A new instance of Cat.
- #run ⇒ Object
Constructor Details
#initialize(command, options) ⇒ Cat
Returns a new instance of Cat.
8 9 10 11 12 |
# File 'lib/estool/actions/cat.rb', line 8 def initialize(command,) @cmd = command @data = .except(:host, :port) @server = .slice(:host, :port) end |
Instance Method Details
#cat(action, options, server) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/estool/actions/cat.rb', line 35 def cat(action, , server) client = Estool::Connections.start_conn(server[:host], server[:port]) Estool::Connections.test_conn(client) begin puts client.cat.send(action, ) rescue ArgumentError => args puts " #{args} Usage: 'estool help #{action}' for more information " exit 1 end end |
#format_options(data) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/estool/actions/cat.rb', line 14 def (data) params = {} data.each do |k, v| case k when :verbose params.merge!(v: v) when :output params.merge!(format: v) when :name params.merge!(name: v) when :node params.merge!(node_id: v) when :primary params.merge!(pri: v) else params.merge!("#{k}": v) end end return params end |
#run ⇒ Object
49 50 51 52 |
# File 'lib/estool/actions/cat.rb', line 49 def run params = (@data) cat(@cmd, params, @server) end |