Class: RuboCop::Cop::RSpec::AggregateExamples::Language::SelectorSet

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/cop/rspec/aggregate_examples/language.rb

Overview

Set of method selectors

Instance Method Summary collapse

Constructor Details

#initialize(selectors) ⇒ SelectorSet

Returns a new instance of SelectorSet.



15
16
17
# File 'lib/rubocop/cop/rspec/aggregate_examples/language.rb', line 15

def initialize(selectors)
  @selectors = selectors
end

Instance Method Details

#+(other) ⇒ Object



23
24
25
# File 'lib/rubocop/cop/rspec/aggregate_examples/language.rb', line 23

def +(other)
  self.class.new(selectors + other.selectors)
end

#==(other) ⇒ Object



19
20
21
# File 'lib/rubocop/cop/rspec/aggregate_examples/language.rb', line 19

def ==(other)
  selectors.eql?(other.selectors)
end

#block_patternObject



31
32
33
# File 'lib/rubocop/cop/rspec/aggregate_examples/language.rb', line 31

def block_pattern
  "(block #{send_pattern} ...)"
end

#include?(selector) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/rubocop/cop/rspec/aggregate_examples/language.rb', line 27

def include?(selector)
  selectors.include?(selector)
end

#node_patternObject



43
44
45
# File 'lib/rubocop/cop/rspec/aggregate_examples/language.rb', line 43

def node_pattern
  selectors.map(&:inspect).join(' ')
end

#node_pattern_unionObject



39
40
41
# File 'lib/rubocop/cop/rspec/aggregate_examples/language.rb', line 39

def node_pattern_union
  "{#{node_pattern}}"
end

#send_patternObject



35
36
37
# File 'lib/rubocop/cop/rspec/aggregate_examples/language.rb', line 35

def send_pattern
  "(send #{RSPEC} #{node_pattern_union} ...)"
end