Module: Gosu::Keyboard

Defined in:
lib/gosu/keyboard.rb,
lib/gosu/keyboard/dsl.rb,
lib/gosu/keyboard/dsl/helpers.rb

Defined Under Namespace

Classes: DSL, NoKeyError

Class Method Summary collapse

Class Method Details

.handle_keys(window, &blk) ⇒ Object



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

def handle_keys(window, &blk)
  DSL.new(window, &blk)
end

.keysObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/gosu/keyboard.rb', line 20

def keys
  @keys ||= Gosu.constants.collect(&:to_s).grep(/^Kb/).each_with_object({}) do |constant_name, memo|
    constant = Gosu.const_get(constant_name)
    key_name = constant_name.gsub(/^Kb/, '').underscore.gsub(/numpad(\d)/, 'numpad_\1')
    
    key_name = case key_name
      when '0' then :zero
      when '1' then :one
      when '2' then :two
      when '3' then :three
      when '4' then :four
      when '5' then :five
      when '6' then :six
      when '7' then :seven
      when '8' then :eight
      when '9' then :nine
      else
        key_name.to_sym
    end
    
    memo[key_name] = constant
  end
end

.register(mod) ⇒ Object



48
49
50
# File 'lib/gosu/keyboard.rb', line 48

def register(mod)
  DSL.send(:include, mod)
end