Module: Leftovers::MatcherBuilders::Node
- Defined in:
- lib/leftovers/matcher_builders/node.rb
Class Method Summary collapse
- .build(patterns) ⇒ Object
-
.build_from_hash(names: nil, match: nil, has_prefix: nil, has_suffix: nil, document: false, paths: nil, has_arguments: nil, has_receiver: nil, has_block: nil, type: nil, privacy: nil, unless_arg: nil, all: nil, any: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists, Metrics/MethodLength.
Class Method Details
.build(patterns) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/leftovers/matcher_builders/node.rb', line 7 def build(patterns) Or.each_or_self(patterns) do |pattern| case pattern 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 |
.build_from_hash(names: nil, match: nil, has_prefix: nil, has_suffix: nil, document: false, paths: nil, has_arguments: nil, has_receiver: nil, has_block: nil, type: nil, privacy: nil, unless_arg: nil, all: nil, any: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/leftovers/matcher_builders/node.rb', line 19 def build_from_hash( # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength names: nil, match: nil, has_prefix: nil, has_suffix: nil, document: false, paths: nil, has_arguments: nil, has_receiver: nil, has_block: nil, type: nil, privacy: nil, unless_arg: nil, all: nil, any: nil ) And.build([ build_node_name_matcher(names, match, has_prefix, has_suffix), Document.build(document), NodePath.build(paths), NodeHasArgument.build(has_arguments), NodeHasBlock.build(has_block), NodeHasReceiver.build(has_receiver), NodePrivacy.build(privacy), NodeType.build(type), Unless.build(build(unless_arg)), build_all_matcher(all), build(any) ]) end |