Class: Twiddler::Config::KeyTable::KeyData
- Inherits:
- 
      Object
      
        - Object
- Twiddler::Config::KeyTable::KeyData
 
- Defined in:
- lib/twiddler/config.rb
Constant Summary collapse
- ModAliases =
- Hash.new{|h,k| k}.merge!( "rsft" => "shift", "lsft" => "shift", "rctl" => "control", "lctl" => "control", "lalt" => "alt", "ralt" => "alt", "lgui" => "gui", "rgui" => "gui" ) 
Instance Attribute Summary collapse
- 
  
    
      #code  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute code. 
Class Method Summary collapse
Instance Method Summary collapse
- #===(chord) ⇒ Object
- #has_mod?(mod) ⇒ Boolean
- 
  
    
      #initialize(num, name)  ⇒ KeyData 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of KeyData. 
- #modified(mod, value) ⇒ Object
- #normalized(mod) ⇒ Object
- #string(mod = nil) ⇒ Object
- #tag(name) ⇒ Object
- #tag?(name) ⇒ Boolean
Constructor Details
#initialize(num, name) ⇒ KeyData
Returns a new instance of KeyData.
| 16 17 18 19 20 | # File 'lib/twiddler/config.rb', line 16 def initialize(num, name) @code = num @data = { :unmod => name } = {} end | 
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
| 21 22 23 | # File 'lib/twiddler/config.rb', line 21 def code @code end | 
Class Method Details
.normalized(mod) ⇒ Object
| 52 53 54 55 56 57 | # File 'lib/twiddler/config.rb', line 52 def self.normalized(mod) unless Array === mod mod = mod.split("-") end return mod.map{|i| ModAliases[i.downcase]}.sort.join("-") end | 
Instance Method Details
#===(chord) ⇒ Object
| 48 49 50 | # File 'lib/twiddler/config.rb', line 48 def ===(chord) chord.single? and chord[0][0] == @code end | 
#has_mod?(mod) ⇒ Boolean
| 44 45 46 | # File 'lib/twiddler/config.rb', line 44 def has_mod?(mod) @data.has_key?(normalized(mod)) end | 
#modified(mod, value) ⇒ Object
| 31 32 33 | # File 'lib/twiddler/config.rb', line 31 def modified(mod, value) @data[normalized(mod)] = value end | 
#normalized(mod) ⇒ Object
| 59 60 61 | # File 'lib/twiddler/config.rb', line 59 def normalized(mod) self.class.normalized(mod) end | 
#string(mod = nil) ⇒ Object
| 35 36 37 38 39 40 41 42 | # File 'lib/twiddler/config.rb', line 35 def string(mod=nil) return @data[:unmod] if mod.nil? or mod.empty? if data = @data[normalized(mod)] return data else return "#{mod}-#{@data[:unmod]}" end end | 
#tag(name) ⇒ Object
| 23 24 25 | # File 'lib/twiddler/config.rb', line 23 def tag(name) [name.to_sym] = true end | 
#tag?(name) ⇒ Boolean
| 27 28 29 | # File 'lib/twiddler/config.rb', line 27 def tag?(name) .has_key?(name) end |