Sha256: 6abd279dcb582d0789918f70809bdacbdaa2108e4ee837862b834af6f4b5180e

Contents?: true

Size: 776 Bytes

Versions: 2

Compression:

Stored size: 776 Bytes

Contents

# A mission which completes anywhere i.e. even after non word break characters such as '[' or '}'.
# It generates the following regexp condition /#{prefix}(#{anywhere})$/ and passes the first
# capture group to the mission action.
#
# ==== Bond.complete Options:
# [*:anywhere*] A regexp string which generates the first capture group in the above regexp.
# [*:prefix*] An optional string which prefixes the first capture group in the above regexp.
class Bond::AnywhereMission < Bond::Mission
  def initialize(options={}) #:nodoc:
    options[:on] = Regexp.new("#{options[:prefix]}(#{options[:anywhere]})$")
    super
  end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bond-0.2.1 lib/bond/missions/anywhere_mission.rb
bond-0.2.0 lib/bond/missions/anywhere_mission.rb