Module: Leftovers::MatcherBuilders::NodeValue
- Defined in:
- lib/leftovers/matcher_builders/node_value.rb
Class Method Summary collapse
Class Method Details
.build(patterns) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/leftovers/matcher_builders/node_value.rb', line 7 def build(patterns) Or.each_or_self(patterns) do |pattern| case pattern when ::Integer, ::Float, true, false then Matchers::NodeScalarValue.new(pattern) # matching scalar on nil will fall afoul of compact and each_or_self etc. when :_leftovers_nil_value then Matchers::NodeType.new(:nil) when ::String then NodeName.build(pattern) when ::Hash then build_from_hash(**pattern) # :nocov: else raise UnexpectedCase, "Unhandled value #{pattern.inspect}" # :nocov: end end end |