Class: P2::Router
Overview
Represents external Driver for P2 Router server app
Constant Summary collapse
- ROUTER_TITLE =
Regexp.new('P2MQRouter - ')
Constants included from P2
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Router
constructor
A new instance of Router.
- #method_missing(*args) ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Router
Returns a new instance of Router.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/p2ruby/router.rb', line 14 def initialize opts = {} @opts = opts.dup if @opts[:app] @app = @opts[:app] else @opts[:ini] = Pathname(@opts[:ini] || @opts[:ini_file] || "./client_router.ini") error "Wrong ini file name" unless @opts[:ini]..exist? || @opts[:args] @opts[:title] ||= ROUTER_TITLE @opts[:path] ||= @opts[:dir] && @opts[:dir] + 'P2MQRouter.exe' @opts[:args] ||= "/ini:#{@opts[:ini]}" @opts[:timeout] ||= 3 @app = ::WinGui::App.launch(:dir => @opts[:dir], :path => @opts[:path], :args => @opts[:args], :title => @opts[:title], :timeout => @opts[:timeout]) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args) ⇒ Object
35 36 37 |
# File 'lib/p2ruby/router.rb', line 35 def method_missing *args @app.send *args end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
12 13 14 |
# File 'lib/p2ruby/router.rb', line 12 def app @app end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
12 13 14 |
# File 'lib/p2ruby/router.rb', line 12 def opts @opts end |
Class Method Details
.find ⇒ Object
7 8 9 10 |
# File 'lib/p2ruby/router.rb', line 7 def self.find router = ::WinGui::App.find :title => ROUTER_TITLE router ? new(:app => router) : nil end |
Instance Method Details
#title ⇒ Object
39 40 41 |
# File 'lib/p2ruby/router.rb', line 39 def title @app.main_window.title end |