Module: Leftovers::MatcherBuilders::NodeType
- Defined in:
- lib/leftovers/matcher_builders/node_type.rb
Class Method Summary collapse
-
.build(types_pattern) ⇒ Object
rubocop:disable Metrics.
Class Method Details
.build(types_pattern) ⇒ Object
rubocop:disable Metrics
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/leftovers/matcher_builders/node_type.rb', line 8 def self.build(types_pattern) # rubocop:disable Metrics Or.each_or_self(types_pattern) do |type| case type when :Symbol then Matchers::NodeType.new(:sym) when :String then Matchers::NodeType.new(:str) when :Integer then Matchers::NodeType.new(:int) when :Float then Matchers::NodeType.new(:float) when :Array then Matchers::NodeType.new(:array) when :Hash then Matchers::NodeType.new(:hash) when :Proc then Matchers::NodeIsProc when :Method Matchers::NodeType.new( ::Set[:send, :csend, :def, :defs].compare_by_identity.freeze ) when :Constant Matchers::NodeType.new( ::Set[:const, :class, :module, :casgn].compare_by_identity.freeze ) # :nocov: else raise UnexpectedCase, "Unhandled value #{type.inspect}" # :nocov: end end end |