Class: TheBigUsernameBlacklist::Data
- Inherits:
-
Object
- Object
- TheBigUsernameBlacklist::Data
- Defined in:
- lib/the_big_username_blacklist/data.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(usernames) ⇒ Data
constructor
A new instance of Data.
- #match?(username) ⇒ Boolean
Constructor Details
#initialize(usernames) ⇒ Data
Returns a new instance of Data.
9 10 11 12 13 |
# File 'lib/the_big_username_blacklist/data.rb', line 9 def initialize(usernames) @usernames = usernames.each_with_object({}) do |username, hash| hash[username] = true end end |
Class Method Details
.default ⇒ Object
3 4 5 6 7 |
# File 'lib/the_big_username_blacklist/data.rb', line 3 def self.default file_path = File.('../../../data/list.txt', __FILE__) usernames = File.open(file_path, 'r').read.split("\n") new(usernames) end |
Instance Method Details
#match?(username) ⇒ Boolean
15 16 17 |
# File 'lib/the_big_username_blacklist/data.rb', line 15 def match?(username) @usernames[username] || false end |