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.



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

def initialize
  @custom_path = nil
  reload
end

Instance Attribute Details

#custom_pathObject

Returns the value of attribute custom_path.



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

def custom_path
  @custom_path
end

#keymapObject (readonly)

Returns the value of attribute keymap.



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

def keymap
  @keymap
end

Class Method Details

.interval(action_type) ⇒ Object



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

def interval(action_type)
  instance.interval(action_type)
end

.reloadObject



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

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

#interval(action_type) ⇒ Object



50
51
52
53
# File 'lib/fusuma/config.rb', line 50

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

#reloadObject



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

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

#shortcut(gesture_info) ⇒ Object



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

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

#threshold(action_type) ⇒ Object



45
46
47
48
# File 'lib/fusuma/config.rb', line 45

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