Class: Ursa::Packages::KeyDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/ursa/packages/system_events.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ursa) ⇒ KeyDSL

Returns a new instance of KeyDSL.



5
6
7
8
9
# File 'lib/ursa/packages/system_events.rb', line 5

def initialize(ursa)
  self.ursa = ursa
  self.normal_keys = []
  self.special_keys = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ursa/packages/system_events.rb', line 11

def method_missing(meth, *args, &block)
  key, kind = ursa.key_and_kind(meth.to_sym)
  if key.nil?
    key, kind = ursa.key_and_kind(meth.to_s.upcase)
  end

  if kind == :normal
    normal_keys << key
  elsif kind == :special
    special_keys << key
  end
end

Instance Attribute Details

#normal_keysObject

Returns the value of attribute normal_keys.



3
4
5
# File 'lib/ursa/packages/system_events.rb', line 3

def normal_keys
  @normal_keys
end

#special_keysObject

Returns the value of attribute special_keys.



3
4
5
# File 'lib/ursa/packages/system_events.rb', line 3

def special_keys
  @special_keys
end

#ursaObject

Returns the value of attribute ursa.



3
4
5
# File 'lib/ursa/packages/system_events.rb', line 3

def ursa
  @ursa
end