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
- .command(event_trigger) ⇒ Object
- .interval(action_type) ⇒ Object
- .reload ⇒ Object
- .shortcut(event_trigger) ⇒ Object
- .threshold(action_type) ⇒ Object
Instance Method Summary collapse
- #command(event_trigger) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #interval(action_type) ⇒ Object
- #reload ⇒ Object
- #shortcut(event_trigger) ⇒ Object
- #threshold(action_type) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
33 34 35 36 |
# File 'lib/fusuma/config.rb', line 33 def initialize @custom_path = nil reload end |
Instance Attribute Details
#custom_path ⇒ Object
Returns the value of attribute custom_path.
31 32 33 |
# File 'lib/fusuma/config.rb', line 31 def custom_path @custom_path end |
#keymap ⇒ Object (readonly)
Returns the value of attribute keymap.
30 31 32 |
# File 'lib/fusuma/config.rb', line 30 def keymap @keymap end |
Class Method Details
.command(event_trigger) ⇒ Object
9 10 11 |
# File 'lib/fusuma/config.rb', line 9 def command(event_trigger) instance.command(event_trigger) end |
.interval(action_type) ⇒ Object
21 22 23 |
# File 'lib/fusuma/config.rb', line 21 def interval(action_type) instance.interval(action_type) end |
.reload ⇒ Object
25 26 27 |
# File 'lib/fusuma/config.rb', line 25 def reload instance.reload end |
.shortcut(event_trigger) ⇒ Object
13 14 15 |
# File 'lib/fusuma/config.rb', line 13 def shortcut(event_trigger) instance.shortcut(event_trigger) end |
.threshold(action_type) ⇒ Object
17 18 19 |
# File 'lib/fusuma/config.rb', line 17 def threshold(action_type) instance.threshold(action_type) end |
Instance Method Details
#command(event_trigger) ⇒ Object
44 45 46 47 |
# File 'lib/fusuma/config.rb', line 44 def command(event_trigger) seek_index = [*action_index(event_trigger), 'command'] cache(seek_index) { search_config(keymap, seek_index) } end |
#interval(action_type) ⇒ Object
59 60 61 62 |
# File 'lib/fusuma/config.rb', line 59 def interval(action_type) seek_index = ['interval', action_type] cache(seek_index) { search_config(keymap, seek_index) } || 1 end |
#reload ⇒ Object
38 39 40 41 42 |
# File 'lib/fusuma/config.rb', line 38 def reload @cache = nil @keymap = YAML.load_file(file_path) self end |
#shortcut(event_trigger) ⇒ Object
49 50 51 52 |
# File 'lib/fusuma/config.rb', line 49 def shortcut(event_trigger) seek_index = [*action_index(event_trigger), 'shortcut'] cache(seek_index) { search_config(keymap, seek_index) } end |
#threshold(action_type) ⇒ Object
54 55 56 57 |
# File 'lib/fusuma/config.rb', line 54 def threshold(action_type) seek_index = ['threshold', action_type] cache(seek_index) { search_config(keymap, seek_index) } || 1 end |