Class: Joyce::Application
- Inherits:
-
Object
- Object
- Joyce::Application
- Defined in:
- lib/joyce/application.rb
Constant Summary collapse
- DEFAULT_WIDTH =
1920
- DEFAULT_HEIGHT =
1080
Class Attribute Summary collapse
-
.view_class ⇒ Object
readonly
Returns the value of attribute view_class.
Class Method Summary collapse
- .connect_immediately? ⇒ Boolean
- .kickstart!(headless: false, setup: {}) ⇒ Object
- .simulation_class ⇒ Object
- .viewed_with(view_class) ⇒ Object
Instance Method Summary collapse
- #click ⇒ Object
- #fire(cmd) ⇒ Object
- #height ⇒ Object
-
#initialize(headless: false) ⇒ Application
constructor
A new instance of Application.
- #launch(*setup_args) ⇒ Object
- #press ⇒ Object
- #received_events ⇒ Object
- #setup ⇒ Object
- #sim ⇒ Object
- #tick ⇒ Object
- #view ⇒ Object
- #width ⇒ Object
- #window ⇒ Object
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_class ⇒ Object (readonly)
Returns the value of attribute view_class.
79 80 81 |
# File 'lib/joyce/application.rb', line 79 def view_class @view_class end |
Class Method Details
.connect_immediately? ⇒ Boolean
53 54 55 |
# File 'lib/joyce/application.rb', line 53 def self.connect_immediately? false end |
.kickstart!(headless: false, setup: {}) ⇒ Object
85 86 87 88 89 |
# File 'lib/joyce/application.rb', line 85 def kickstart!(headless: false, setup: {}) app = new(headless: headless) app.launch(setup) app end |
.simulation_class ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/joyce/application.rb', line 45 def self.simulation_class if connect_immediately? RemoteSim else Metacosm::Simulation end end |
.viewed_with(view_class) ⇒ Object
80 81 82 83 |
# File 'lib/joyce/application.rb', line 80 def viewed_with(view_class) @view_class ||= view_class self end |
Instance Method Details
#click ⇒ Object
18 19 20 |
# File 'lib/joyce/application.rb', line 18 def click # ... end |
#fire(cmd) ⇒ Object
33 34 35 |
# File 'lib/joyce/application.rb', line 33 def fire(cmd) sim.fire(cmd) end |
#height ⇒ Object
69 70 71 |
# File 'lib/joyce/application.rb', line 69 def height DEFAULT_HEIGHT end |
#launch(*setup_args) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/joyce/application.rb', line 26 def launch(*setup_args) sim.conduct! setup(*setup_args) window.show self end |
#press ⇒ Object
22 23 24 |
# File 'lib/joyce/application.rb', line 22 def press(*) # ... end |
#received_events ⇒ Object
37 38 39 |
# File 'lib/joyce/application.rb', line 37 def received_events sim.received_events end |
#setup ⇒ Object
10 11 12 |
# File 'lib/joyce/application.rb', line 10 def setup(*) # ... end |
#sim ⇒ Object
41 42 43 |
# File 'lib/joyce/application.rb', line 41 def sim @simulation ||= self.class.simulation_class.current # RemoteSim.current end |
#tick ⇒ Object
14 15 16 |
# File 'lib/joyce/application.rb', line 14 def tick # ... end |
#view ⇒ Object
57 58 59 |
# File 'lib/joyce/application.rb', line 57 def view @view ||= construct_view end |
#width ⇒ Object
65 66 67 |
# File 'lib/joyce/application.rb', line 65 def width DEFAULT_WIDTH end |
#window ⇒ Object
61 62 63 |
# File 'lib/joyce/application.rb', line 61 def window @window ||= @headless ? NullWindow.new(self) : ApplicationWindow.new(self, width: width, height: height) end |