Class: MeshChat::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/meshchat/instance.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Instance

Returns a new instance of Instance.



20
21
22
23
# File 'lib/meshchat/instance.rb', line 20

def initialize(options = {})
  self.client_name = options[:client_name] || MeshChat::NAME
  self.client_version = options[:client_version] || MeshChat::VERSION
end

Instance Attribute Details

#client_nameObject

Returns the value of attribute client_name.



3
4
5
# File 'lib/meshchat/instance.rb', line 3

def client_name
  @client_name
end

#client_versionObject

Returns the value of attribute client_version.



3
4
5
# File 'lib/meshchat/instance.rb', line 3

def client_version
  @client_version
end

#displayObject

Returns the value of attribute display.



3
4
5
# File 'lib/meshchat/instance.rb', line 3

def display
  @display
end

Class Method Details

.instanceObject



15
16
17
# File 'lib/meshchat/instance.rb', line 15

def instance
  @instance
end

.start(options) ⇒ Object



9
10
11
12
13
# File 'lib/meshchat/instance.rb', line 9

def start(options)
  # calling instance to get things going
  @instance = new(options)
  @instance.start_ui(options[:display], options[:on_display_start])
end

Instance Method Details

#start_ui(klass, on_display_start) ⇒ Object

Parameters:

  • klass (class)

    should be something that implements Display::Base

  • proc (Proc)

    what to do when starting the UI



27
28
29
30
31
32
# File 'lib/meshchat/instance.rb', line 27

def start_ui(klass, on_display_start)
  self.display = Display::Manager.new(klass)
  display.start do
    on_display_start.call if on_display_start
  end
end