Class: Fusuma::Plugin::Events::Records::IndexRecord
- Defined in:
- lib/fusuma/plugin/events/records/index_record.rb
Overview
Vector Record have index
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#index ⇒ Object
define gesture format.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#trigger ⇒ Object
readonly
Returns the value of attribute trigger.
Instance Method Summary collapse
- #exist_on_conf?(index = @index) ⇒ Boolean
-
#initialize(index:, position: :body, trigger: :oneshot, args: {}) ⇒ IndexRecord
constructor
A new instance of IndexRecord.
- #mergable? ⇒ Boolean
-
#merge(records:, index: @index) ⇒ IndexRecord, NilClass
FIXME: move to Config::Index.
- #trigger_priority ⇒ Integer
- #type ⇒ Object
Methods inherited from Base
#config_index, #config_param_types, #config_params, inherited, plugins
Methods included from CustomProcess
Constructor Details
#initialize(index:, position: :body, trigger: :oneshot, args: {}) ⇒ IndexRecord
17 18 19 20 21 22 23 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 17 def initialize(index:, position: :body, trigger: :oneshot, args: {}) super() @index = index @position = position @trigger = trigger @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
12 13 14 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 12 def args @args end |
#index ⇒ Object
define gesture format
11 12 13 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 11 def index @index end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
12 13 14 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 12 def position @position end |
#trigger ⇒ Object (readonly)
Returns the value of attribute trigger.
12 13 14 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 12 def trigger @trigger end |
Instance Method Details
#exist_on_conf?(index = @index) ⇒ Boolean
59 60 61 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 59 def exist_on_conf?(index = @index) Config.search(index) end |
#mergable? ⇒ Boolean
75 76 77 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 75 def mergable? @position == :body end |
#merge(records:, index: @index) ⇒ IndexRecord, NilClass
FIXME: move to Config::Index
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 33 def merge(records:, index: @index) # FIXME: cache raise "position is NOT body: #{self}" unless mergable? if records.empty? if Config.find_execute_key(index) @index = index return self end return nil end record = records.shift new_index = case record.position when :surfix Config::Index.new([*index.keys, *record.index.keys]) else raise "invalid index position: #{record}" end return unless exist_on_conf?(new_index) merge(records: records, index: new_index) end |
#trigger_priority ⇒ Integer
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 64 def trigger_priority case @trigger when :oneshot 10 when :repeat 100 else 1000 end end |
#type ⇒ Object
25 26 27 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 25 def type :index end |