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.
-
#merge(records:, index: @index) ⇒ IndexRecord, NilClass
FIXME: move to Config::Index.
- #mergeable? ⇒ Boolean
- #to_s ⇒ Object
- #trigger_priority ⇒ Integer
- #type ⇒ Object
Methods inherited from Base
#config_index, #config_param_types, #config_params, inherited, plugins, #shutdown
Constructor Details
#initialize(index:, position: :body, trigger: :oneshot, args: {}) ⇒ IndexRecord
Returns a new instance of 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
63 64 65 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 63 def exist_on_conf?(index = @index) Config.search(index) end |
#merge(records:, index: @index) ⇒ IndexRecord, NilClass
FIXME: move to Config::Index
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 37 def merge(records:, index: @index) # FIXME: cache raise "position is NOT body: #{self}" unless mergeable? if records.empty? if Config.instance.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 |
#mergeable? ⇒ Boolean
79 80 81 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 79 def mergeable? @position == :body end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 25 def to_s "#{@index}, #{@position}, #{@trigger}, #{@args}" end |
#trigger_priority ⇒ Integer
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 68 def trigger_priority case @trigger when :oneshot 10 when :repeat 100 else 1000 end end |
#type ⇒ Object
29 30 31 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 29 def type :index end |