class Fusuma::Plugin::Events::Records::IndexRecord
Vector Record
have index
Attributes
args[R]
index[RW]
define gesture format
position[R]
trigger[R]
Public Class Methods
new(index:, position: :body, trigger: :oneshot, args: {})
click to toggle source
@param [Config::Index] index @param [Symbol] position [:prefix, :body, :surfix] @param [Symbol] trigger [:oneshot, :repeat]
Calls superclass method
# 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
Public Instance Methods
exist_on_conf?(index = @index)
click to toggle source
@param [Config::Searcher] searcher
# File lib/fusuma/plugin/events/records/index_record.rb, line 59 def exist_on_conf?(index = @index) Config.search(index) end
mergable?()
click to toggle source
# File lib/fusuma/plugin/events/records/index_record.rb, line 75 def mergable? @position == :body end
merge(records:, index: @index)
click to toggle source
FIXME: move to Config::Index
@param records [Array<IndexRecord>] @return [IndexRecord] when merge is succeeded @return [NilClass] when merge is not succeeded
# 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()
click to toggle source
@return [Integer]
# 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()
click to toggle source
# File lib/fusuma/plugin/events/records/index_record.rb, line 25 def type :index end