Class: FSR::App::Bridge

Inherits:
Application show all
Defined in:
lib/fsr/app/bridge.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Application

#app_name, #sendmsg, #to_s

Constructor Details

#initialize(*params) ⇒ Bridge

Returns a new instance of Bridge.



8
9
10
11
12
# File 'lib/fsr/app/bridge.rb', line 8

def initialize(*params)
  @options = params.last.is_a?(Hash) ? params.pop : {}
  @sequential = @options.delete(:sequential)
  @targets = params
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/fsr/app/bridge.rb', line 6

def options
  @options
end

Class Method Details

.execute(target, opts = {}) ⇒ Object



27
28
29
# File 'lib/fsr/app/bridge.rb', line 27

def self.execute(target, opts = {})
  self.new(target, opts).raw
end

Instance Method Details

#argumentsObject



14
15
16
17
# File 'lib/fsr/app/bridge.rb', line 14

def arguments
  delimeter = @sequential ? "|" : ","
  [@targets.join(delimeter)]
end

#modifiersObject



19
20
21
# File 'lib/fsr/app/bridge.rb', line 19

def modifiers
  @options.map { |k,v| "%s=%s" % [k, v] }.join(",")
end

#rawObject



23
24
25
# File 'lib/fsr/app/bridge.rb', line 23

def raw
  "%s({%s}%s)" % [app_name, modifiers, arguments.join(" ")]
end