Module: FMS::CmdLine::MethodCaller

Defined in:
lib/fms/cmdline.rb

Class Method Summary collapse

Class Method Details

.call(method, params) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/fms/cmdline.rb', line 73

def call(method, params)
  init_params = filter_init_params params
  begin
    c = FMS::Client.new(init_params)
    Output.stdout c.send(method.to_sym, params).to_s
  rescue ArgumentError => error
    Output.stderr error.message.gsub(':','--')
  rescue NoMethodError => error
    Output.stderr error.message
  end
end

.filter_init_params(params) ⇒ Object



85
86
87
88
89
90
91
92
93
94
# File 'lib/fms/cmdline.rb', line 85

def filter_init_params(params)
  init_params = {}
  params.each_pair do |key,value| 
    if init_param? key
      init_params[key] = value
      params.delete key
    end
  end
  init_params
end

.init_param?(param) ⇒ Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/fms/cmdline.rb', line 96

def init_param?(param)
  [:host, :port, :auser, :apswd, :timeout].include? param
end