Class: Fusuma::Config
- Inherits:
-
Object
- Object
- Fusuma::Config
- Includes:
- Singleton
- Defined in:
- lib/fusuma/config.rb
Overview
read keymap from yaml file
Instance Attribute Summary collapse
-
#custom_path ⇒ Object
Returns the value of attribute custom_path.
-
#keymap ⇒ Object
readonly
Returns the value of attribute keymap.
Class Method Summary collapse
- .interval(action_type) ⇒ Object
- .reload ⇒ Object
- .shortcut(gesture_info) ⇒ Object
- .threshold(action_type) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #interval(action_type) ⇒ Object
- #reload ⇒ Object
- #shortcut(gesture_info) ⇒ Object
- #threshold(action_type) ⇒ Object
Constructor Details
#initialize ⇒ Config
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_path ⇒ Object
Returns the value of attribute custom_path.
27 28 29 |
# File 'lib/fusuma/config.rb', line 27 def custom_path @custom_path end |
#keymap ⇒ Object (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 |
.reload ⇒ Object
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 |
#reload ⇒ Object
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 |