Class: Ray::KeyMod
- Inherits:
-
Object
- Object
- Ray::KeyMod
- Defined in:
- lib/ray/dsl/matcher.rb
Overview
A KeyMod object can be used as a matcher to check if some modifiers are held when a key is pressed.
Instance Method Summary collapse
- #===(other) ⇒ Object
-
#initialize(name) ⇒ KeyMod
constructor
A new instance of KeyMod.
- #inspect ⇒ Object
- #to_a ⇒ Object
- #to_sym ⇒ Object
Constructor Details
#initialize(name) ⇒ KeyMod
Returns a new instance of KeyMod.
221 222 223 224 |
# File 'lib/ray/dsl/matcher.rb', line 221 def initialize(name) raise NoKeyError, name unless Mod[name] @symbol = name.to_sym end |
Instance Method Details
#===(other) ⇒ Object
234 235 236 |
# File 'lib/ray/dsl/matcher.rb', line 234 def ===(other) other.is_a?(Integer) && to_a.any? { |const| (o & const) != 0 } end |
#inspect ⇒ Object
238 239 240 |
# File 'lib/ray/dsl/matcher.rb', line 238 def inspect "key_mod(#{to_sym})" end |
#to_a ⇒ Object
226 227 228 |
# File 'lib/ray/dsl/matcher.rb', line 226 def to_a Mod[@symbol] end |
#to_sym ⇒ Object
230 231 232 |
# File 'lib/ray/dsl/matcher.rb', line 230 def to_sym @symbol end |