Sha256: 8879eec63dfde816179ccbfac803dc2e02259b00205242765941609bf8cd3da2

Contents?: true

Size: 1.1 KB

Versions: 7

Compression:

Stored size: 1.1 KB

Contents

# frozen-string-literal: true

require 'set'

module Leftovers
  module MatcherBuilders
    module NodeType
      def self.build(types_pattern) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
        ::Leftovers::MatcherBuilders::Or.each_or_self(types_pattern) do |type|
          case type
          when 'Symbol' then ::Leftovers::Matchers::NodeType.new(:sym)
          when 'String' then ::Leftovers::Matchers::NodeType.new(:str)
          when 'Integer' then ::Leftovers::Matchers::NodeType.new(:int)
          when 'Float' then ::Leftovers::Matchers::NodeType.new(:float)
          when 'Array' then ::Leftovers::Matchers::NodeType.new(:array)
          when 'Hash' then ::Leftovers::Matchers::NodeType.new(:hash)

          when 'Proc' then ::Leftovers::Matchers::Predicate.new(:proc?)
          # when 'Method' then ::Leftovers::Matchers::NodeType.new(Set[:send, :csend, :def])
          # when 'Constant' then ::Leftovers::Matchers::NodeType.new(Set[:const, :class, :module])
          # :nocov:
          else raise
            # :nocov:
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
leftovers-0.6.0 lib/leftovers/matcher_builders/node_type.rb
leftovers-0.5.5 lib/leftovers/matcher_builders/node_type.rb
leftovers-0.5.4 lib/leftovers/matcher_builders/node_type.rb
leftovers-0.5.3 lib/leftovers/matcher_builders/node_type.rb
leftovers-0.5.2 lib/leftovers/matcher_builders/node_type.rb
leftovers-0.5.1 lib/leftovers/matcher_builders/node_type.rb
leftovers-0.5.0 lib/leftovers/matcher_builders/node_type.rb