Class: TheBigUsernameBlacklist::Data

Inherits:
Object
  • Object
show all
Defined in:
lib/the_big_username_blacklist/data.rb

Class Method Summary collapse

Instance Method Summary collapse

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

.defaultObject



3
4
5
6
7
# File 'lib/the_big_username_blacklist/data.rb', line 3

def self.default
  file_path = File.expand_path('../../../data/list.txt', __FILE__)
  usernames = File.open(file_path, 'r').read.split("\n")
  new(usernames)
end

Instance Method Details

#match?(username) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/the_big_username_blacklist/data.rb', line 15

def match?(username)
  @usernames[username] || false
end