Sha256: e9de6423a45440d79070dd4252e68515462f059a452f6e431a14a0118406be9a

Contents?: true

Size: 950 Bytes

Versions: 10

Compression:

Stored size: 950 Bytes

Contents

module Bond
  # A mission which completes arguments for any module/class method that is an
  # operator i.e. '>' or '*'.  Takes same Bond.complete options as
  # MethodMission. The only operator method this mission doesn't complete is
  # '[]='. The operator '[]' should cover the first argument completion of '[]='
  # anyways.
  class OperatorMethodMission < MethodMission
    OPERATORS = Mission::OPERATORS - ["[]", "[]="]
    OBJECTS = Mission::OBJECTS + %w{\S+}
    CONDITION = %q{(OBJECTS)\s*(METHODS)\s*(['":])?(.*)$}

    protected
    def current_methods
      (OPERATORS & MethodMission.action_methods) + ['[']
    end

    def matched_method
      {'['=>'[]'}[@matched[2]] || @matched[2]
    end

    def after_match(input)
      set_action_and_search
      @completion_prefix, typed = input.to_s.sub(/#{Regexp.quote(@matched[-1])}$/, ''), @matched[-1]
      create_input typed, :object => @evaled_object, :argument => 1
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bond-0.5.1 lib/bond/missions/operator_method_mission.rb
bond-0.5.1-java lib/bond/missions/operator_method_mission.rb
bond-0.5.0 lib/bond/missions/operator_method_mission.rb
bond-0.5.0-java lib/bond/missions/operator_method_mission.rb
bond-0.4.3 lib/bond/missions/operator_method_mission.rb
bond-0.4.3-java lib/bond/missions/operator_method_mission.rb
bond-0.4.2 lib/bond/missions/operator_method_mission.rb
bond-0.4.2-java lib/bond/missions/operator_method_mission.rb
bond-0.4.1 lib/bond/missions/operator_method_mission.rb
bond-0.4.0 lib/bond/missions/operator_method_mission.rb