class TerminalGameEngine::Engine

Constants

DEFAULT_TICK_SLEEP

Attributes

tick[RW]
tick_sleep[RW]

Public Class Methods

new(tick_sleep: DEFAULT_TICK_SLEEP, &block) click to toggle source
# File lib/terminal_game_engine/engine.rb, line 11
def initialize(tick_sleep: DEFAULT_TICK_SLEEP, &block)
  @tick = 0
  @block = block
  @tick_sleep = tick_sleep
end
tick(*args, &block) click to toggle source
# File lib/terminal_game_engine/engine.rb, line 7
def self.tick(*args, &block)
  self.new(*args, &block).tap(&:call)
end

Public Instance Methods

call() click to toggle source
# File lib/terminal_game_engine/engine.rb, line 17
def call
  loop do
    @block.call @tick
    @tick += 1
    sleep tick_sleep
  end
end