Module: Smalruby

Extended by:
ActiveSupport::Autoload
Defined in:
lib/smalruby.rb,
lib/smalruby/util.rb,
lib/smalruby/color.rb,
lib/smalruby/stage.rb,
lib/smalruby/world.rb,
lib/smalruby/canvas.rb,
lib/smalruby/console.rb,
lib/smalruby/version.rb,
lib/smalruby/hardware.rb,
lib/smalruby/character.rb,
lib/smalruby/hardware/led.rb,
lib/smalruby/hardware/pin.rb,
lib/smalruby/event_handler.rb,
lib/smalruby/hardware/servo.rb,
lib/smalruby/hardware/button.rb,
lib/smalruby/hardware/sensor.rb,
lib/smalruby/hardware/motor_driver.rb,
lib/smalruby/hardware/null_hardware.rb,
lib/smalruby/hardware/rgb_led_anode.rb,
lib/smalruby/hardware/rgb_led_cathode.rb,
lib/smalruby/hardware/two_wheel_drive_car.rb

Defined Under Namespace

Modules: Color, Hardware, Util Classes: Canvas, Character, Console, EventHandler, Stage, World

Constant Summary collapse

VERSION =
'0.0.32'

Class Method Summary collapse

Class Method Details

.awaitObject



48
49
50
51
52
53
54
55
56
# File 'lib/smalruby.rb', line 48

def await
  if Thread.current == Thread.main
    sleep(1.0 / 15)
  else
    @draw_mutex.synchronize do
      @draw_cv.wait(@draw_mutex)
    end
  end
end

.init_hardware(options = {}) ⇒ Object



58
59
60
# File 'lib/smalruby.rb', line 58

def init_hardware(options = {})
  Hardware.init(options)
end

.startObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/smalruby.rb', line 24

def start
  @started = true
  begin
    if world.objects.any? { |o| /console/i !~ o.class.name }
      begin
        start_window_application
      ensure
        Hardware.stop
      end
    else
      start_console_application
    end
  rescue SystemExit
  end
end

.started?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/smalruby.rb', line 40

def started?
  return @started
end

.worldObject



44
45
46
# File 'lib/smalruby.rb', line 44

def world
  return World.instance
end