Class: Joyce::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/joyce/application.rb

Constant Summary collapse

DEFAULT_WIDTH =
1920
DEFAULT_HEIGHT =
1080

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(headless: false) ⇒ Application

Returns a new instance of Application.



6
7
8
# File 'lib/joyce/application.rb', line 6

def initialize(headless: false)
  @headless = headless
end

Class Attribute Details

.view_classObject (readonly)

Returns the value of attribute view_class.



75
76
77
# File 'lib/joyce/application.rb', line 75

def view_class
  @view_class
end

Class Method Details

.connect_immediately?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/joyce/application.rb', line 49

def self.connect_immediately?
  false
end

.kickstart!(headless: false, setup: {}) ⇒ Object



81
82
83
84
85
# File 'lib/joyce/application.rb', line 81

def kickstart!(headless: false, setup: {})
  app = new(headless: headless)
  app.launch(setup)
  app
end

.simulation_classObject



41
42
43
44
45
46
47
# File 'lib/joyce/application.rb', line 41

def self.simulation_class
  if connect_immediately?
    RemoteSim
  else
    Metacosm::Simulation
  end
end

.viewed_with(view_class) ⇒ Object



76
77
78
79
# File 'lib/joyce/application.rb', line 76

def viewed_with(view_class)
  @view_class ||= view_class
  self
end

Instance Method Details

#clickObject



18
19
20
# File 'lib/joyce/application.rb', line 18

def click
  # ...
end

#fire(cmd) ⇒ Object



29
30
31
# File 'lib/joyce/application.rb', line 29

def fire(cmd)
  sim.fire(cmd)
end

#heightObject



65
66
67
# File 'lib/joyce/application.rb', line 65

def height
  DEFAULT_HEIGHT
end

#launch(*setup_args) ⇒ Object



22
23
24
25
26
27
# File 'lib/joyce/application.rb', line 22

def launch(*setup_args)
  sim.conduct!
  setup(*setup_args)
  window.show
  self
end

#received_eventsObject



33
34
35
# File 'lib/joyce/application.rb', line 33

def received_events
  sim.received_events
end

#setupObject



10
11
12
# File 'lib/joyce/application.rb', line 10

def setup(*)
  # ...
end

#simObject



37
38
39
# File 'lib/joyce/application.rb', line 37

def sim
  @simulation ||= self.class.simulation_class.current # RemoteSim.current
end

#tickObject



14
15
16
# File 'lib/joyce/application.rb', line 14

def tick
  # ...
end

#viewObject



53
54
55
# File 'lib/joyce/application.rb', line 53

def view
  @view ||= construct_view
end

#widthObject



61
62
63
# File 'lib/joyce/application.rb', line 61

def width
  DEFAULT_WIDTH
end

#windowObject



57
58
59
# File 'lib/joyce/application.rb', line 57

def window
  @window ||= @headless ? NullWindow.new(self) : ApplicationWindow.new(self, width: width, height: height)
end