Sha256: 6ab231228cd0d52911f385e79ee7376b1d177e87e36c7585593455ccd166ad76
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
module Mutest # Abstract base class for match expression class Expression include AbstractType, Adamantium::Flat fragment = /[A-Za-z][A-Za-z\d_]*/ SCOPE_NAME_PATTERN = /(?<scope_name>#{fragment}(?:#{SCOPE_OPERATOR}#{fragment})*)/ SCOPE_SYMBOL_PATTERN = '(?<scope_symbol>[.#])'.freeze private_constant(*constants(false)) # Syntax of expression # # @return [String] abstract_method :syntax # Match length with other expression # # @param [Expression] other # # @return [Integer] def match_length(other) if eql?(other) syntax.length else 0 end end # Test if expression is prefix # # @param [Expression] other # # @return [Boolean] def prefix?(other) !match_length(other).zero? end # Try to parse input into expression of receiver class # # @param [String] input # # @return [Expression] # when successful # # @return [nil] # otherwise def self.try_parse(input) match = self::REGEXP.match(input) return unless match names = anima.attribute_names new(Hash[names.zip(names.map(&match.method(:[])))]) end end # Expression end # Mutest
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mutest-0.0.9 | lib/mutest/expression.rb |