Sha256: 6cfe7eb14d994c9a9126632f579704f6730e0618f48bd125782c461bb91c60e7
Contents?: true
Size: 1.39 KB
Versions: 7
Compression:
Stored size: 1.39 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: scope) } Matcher::Chain.new(matchers: 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
7 entries across 7 versions & 1 rubygems