Class: Fusuma::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/fusuma/config.rb

Overview

read keymap from yaml file

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



22
23
24
# File 'lib/fusuma/config.rb', line 22

def initialize
  reload
end

Instance Attribute Details

#keymapObject

Returns the value of attribute keymap.



25
26
27
# File 'lib/fusuma/config.rb', line 25

def keymap
  @keymap
end

Class Method Details

.reloadObject



17
18
19
# File 'lib/fusuma/config.rb', line 17

def reload
  instance.reload
end

.shortcut(gesture_info) ⇒ Object



9
10
11
# File 'lib/fusuma/config.rb', line 9

def shortcut(gesture_info)
  instance.shortcut(gesture_info)
end

.threshold(action_type) ⇒ Object



13
14
15
# File 'lib/fusuma/config.rb', line 13

def threshold(action_type)
  instance.threshold(action_type)
end

Instance Method Details

#reloadObject



27
28
29
30
31
# File 'lib/fusuma/config.rb', line 27

def reload
  @cache  = nil
  @keymap = YAML.load_file(file_path)
  self
end

#shortcut(gesture_info) ⇒ Object



33
34
35
36
# File 'lib/fusuma/config.rb', line 33

def shortcut(gesture_info)
  seek_index = [*action_index(gesture_info), 'shortcut']
  cache(seek_index) { search_config(keymap, seek_index) }
end

#threshold(action_type) ⇒ Object



38
39
40
41
# File 'lib/fusuma/config.rb', line 38

def threshold(action_type)
  seek_index = ['threshold', action_type]
  cache(seek_index) { search_config(keymap, seek_index) } || 1
end