Class: Bond::AnywhereMission

Inherits:
Mission
  • Object
show all
Defined in:
lib/bond/missions/anywhere_mission.rb

Overview

A mission which completes anywhere i.e. even after non word break characters such as ‘[’ or ‘}’. With options :prefix and :anywhere, this mission matches on the following regexp condition /:prefix?(:anywhere)$/ and passes the first capture group to the mission action.

Constant Summary

Constants inherited from Mission

Mission::OBJECTS, Mission::OPERATORS

Instance Attribute Summary

Attributes inherited from Mission

#action, #matched, #on, #place

Instance Method Summary collapse

Methods inherited from Mission

#call_action, #call_search, #condition, create, current_eval, #do_match, #execute, #match_message, #matches?, #name

Constructor Details

#initialize(options = {}) ⇒ AnywhereMission

Returns a new instance of AnywhereMission.



6
7
8
9
# File 'lib/bond/missions/anywhere_mission.rb', line 6

def initialize(options={}) #@private
  options[:on] = Regexp.new("#{options[:prefix]}(#{options[:anywhere]})$")
  super
end

Instance Method Details

#after_match(input) ⇒ Object



11
12
13
14
# File 'lib/bond/missions/anywhere_mission.rb', line 11

def after_match(input) #@private
  @completion_prefix = input.to_s.sub(/#{Regexp.escape(@matched[1])}$/, '')
  create_input @matched[1]
end