Class: Rubycop::Analyzer::GrayList
- Inherits:
-
Object
- Object
- Rubycop::Analyzer::GrayList
- Defined in:
- lib/rubycop/analyzer/gray_list.rb
Overview
Combination blacklist and whitelist.
Instance Method Summary collapse
-
#allow?(item) ⇒ Boolean
An item is allowed if it’s whitelisted, or if it’s not blacklisted.
- #blacklist(item) ⇒ Object
-
#initialize ⇒ GrayList
constructor
A new instance of GrayList.
- #whitelist(item) ⇒ Object
Constructor Details
#initialize ⇒ GrayList
Returns a new instance of GrayList.
7 8 9 10 |
# File 'lib/rubycop/analyzer/gray_list.rb', line 7 def initialize @blacklist = Set.new @whitelist = Set.new end |
Instance Method Details
#allow?(item) ⇒ Boolean
An item is allowed if it’s whitelisted, or if it’s not blacklisted.
13 14 15 |
# File 'lib/rubycop/analyzer/gray_list.rb', line 13 def allow?(item) @whitelist.include?(item) || !@blacklist.include?(item) end |
#blacklist(item) ⇒ Object
17 18 19 20 |
# File 'lib/rubycop/analyzer/gray_list.rb', line 17 def blacklist(item) @whitelist.delete(item) @blacklist.add(item) end |
#whitelist(item) ⇒ Object
22 23 24 25 |
# File 'lib/rubycop/analyzer/gray_list.rb', line 22 def whitelist(item) @blacklist.delete(item) @whitelist.add(item) end |