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.



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

def initialize
  @custom_path = nil
  reload
end

Instance Attribute Details

#custom_pathObject

Returns the value of attribute custom_path.



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

def custom_path
  @custom_path
end

#keymapObject (readonly)

Returns the value of attribute keymap.



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

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



30
31
32
33
34
# File 'lib/fusuma/config.rb', line 30

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

#shortcut(gesture_info) ⇒ Object



36
37
38
39
# File 'lib/fusuma/config.rb', line 36

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

#threshold(action_type) ⇒ Object



41
42
43
44
# File 'lib/fusuma/config.rb', line 41

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