Sha256: 40ea9e6331d6a615c24833005d208f884de679ef1c3b045c6c645026c5f8ac01

Contents?: true

Size: 604 Bytes

Versions: 7

Compression:

Stored size: 604 Bytes

Contents

# 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.
class Bond::AnywhereMission < Bond::Mission
  def initialize(options={}) #@private
    options[:on] = Regexp.new("#{options[:prefix]}(#{options[:anywhere]})$")
    super
  end

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bond-0.3.5 lib/bond/missions/anywhere_mission.rb
bond-0.3.4 lib/bond/missions/anywhere_mission.rb
bond-0.3.3 lib/bond/missions/anywhere_mission.rb
bond-0.3.2 lib/bond/missions/anywhere_mission.rb
bond-0.3.1 lib/bond/missions/anywhere_mission.rb
bond-0.3.0 lib/bond/missions/anywhere_mission.rb
bond-0.2.2 lib/bond/missions/anywhere_mission.rb