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.



79
80
81
# File 'lib/joyce/application.rb', line 79

def view_class
  @view_class
end

Class Method Details

.connect_immediately?Boolean

Returns:

  • (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_classObject



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

#clickObject



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

#heightObject



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

#pressObject



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

def press(*)
  # ...
end

#received_eventsObject



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

def received_events
  sim.received_events
end

#setupObject



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

def setup(*)
  # ...
end

#simObject



41
42
43
# File 'lib/joyce/application.rb', line 41

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



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

def view
  @view ||= construct_view
end

#widthObject



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

def width
  DEFAULT_WIDTH
end

#windowObject



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