Class: FMS::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/fms/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fms/client.rb', line 10

def initialize(options = {})
  raise ArgumentError, ":host option is required" unless options.include? :host

  defaults = {:auser => 'fms', :apswd => 'fms', :port => 1111}
  defaults.update(options)

  @host = defaults[:host]
  @port = defaults[:port]
  @base_params = {:auser => defaults[:auser], :apswd => defaults[:apswd]}
  @timeout = options[:timeout]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/fms/client.rb', line 22

def method_missing(meth, *args)
  meth = ActiveSupport::Inflector.camelize(meth.to_s, false)
  if args.length == 1
    params = args[0]
  else
    params = {}
  end
  Response.new do_get(meth, camelize_params(params)).strip
end

Instance Attribute Details

#base_paramsObject (readonly)

Returns the value of attribute base_params.



8
9
10
# File 'lib/fms/client.rb', line 8

def base_params
  @base_params
end

#hostObject (readonly)

Returns the value of attribute host.



8
9
10
# File 'lib/fms/client.rb', line 8

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



8
9
10
# File 'lib/fms/client.rb', line 8

def port
  @port
end