Sha256: fae7f20fb4598ea72e45d4bdb3b8a56b67e69efaf9a885c7ed70b36b505cbd10
Contents?: true
Size: 1.37 KB
Versions: 29
Compression:
Stored size: 1.37 KB
Contents
# frozen_string_literal: true module Mutant class Expression # Abstract base class for methods expression class Methods < self include Anima.new( :scope_name, :scope_symbol ) private(*anima.attribute_names) MATCHERS = { '.' => [Matcher::Methods::Singleton, Matcher::Methods::Metaclass].freeze, '#' => [Matcher::Methods::Instance].freeze }.freeze private_constant(*constants(false)) REGEXP = /\A#{SCOPE_NAME_PATTERN}#{SCOPE_SYMBOL_PATTERN}\z/.freeze def initialize(*) super @syntax = [scope_name, scope_symbol].join.freeze end # Syntax of expression # # @return [String] attr_reader :syntax # Matcher on expression # # @return [Matcher::Method] def matcher matcher_candidates = MATCHERS.fetch(scope_symbol) .map { |submatcher| submatcher.new(scope) } Matcher::Chain.new(matcher_candidates) end # Length of match with other expression # # @param [Expression] expression # # @return [Integer] def match_length(expression) if expression.syntax.start_with?(syntax) syntax.length else 0 end end private def scope Object.const_get(scope_name) end end # Methods end # Expression end # Mutant
Version data entries
29 entries across 29 versions & 1 rubygems