Module: RbSDL2::Hint

Defined in:
lib/rb_sdl2/hint.rb

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object

ヒントの設定が行われていないときは nil を戻す。 SDL のデフォルト値はハードコーディングされているためこのメソッドで読み出すことはできない。



6
7
8
9
# File 'lib/rb_sdl2/hint.rb', line 6

def [](name)
  ptr = ::SDL.GetHint(name.to_s)
  ptr.null? ? nil : ptr.read_string
end

.[]=(name, value) ⇒ Object

Raises:



11
12
13
14
# File 'lib/rb_sdl2/hint.rb', line 11

def []=(name, value)
  bool = ::SDL.SetHintWithPriority(name.to_s, value&.to_s, ::SDL::HINT_OVERRIDE)
  raise RbSDL2Error, "failed to set hint" if bool == ::SDL::FALSE
end

.clearObject



16
# File 'lib/rb_sdl2/hint.rb', line 16

def clear = ::SDL.ClearHints

.freezeObject

Raises:

  • (TypeError)


18
# File 'lib/rb_sdl2/hint.rb', line 18

def freeze = raise(TypeError, "cannot freeze Hint")

.include?(name) ⇒ Boolean Also known as: has_key?, member?, key?

Returns:

  • (Boolean)


20
# File 'lib/rb_sdl2/hint.rb', line 20

def include?(name) = ::SDL.GetHintBoolean(name, -1) != -1