gender_detector
gender_detector copied to clipboard
Add class method shortcuts
Just an idea, but what if instead of creating a new detector object, you could simply run:
GenderDetector.get_gender('Sally') # => :female
GenderDetector.female?('Sally') # => true
GenderDetector.male?('Sally') # => false
GenderDetector.androgynous?('Sally') # => false
In this case, configuration would be done like so:
GenderDetector.case_sensitive = false
Or, alternatively:
GenderDetector.configure do |config|
config.case_sensitive = false
end
I’d be open to creating a pull request.
Thanks for the suggestion, @hollingberry. One of the reasons an instance is created is that a data file must be read into memory (which can take a second or two depending on your machine), and I wanted to stay away from having the need for global or class variable that would be set on first call. At least w/ the instance - you know exactly when the file is being loaded (upon instantiation). If class methods were used, when do you think the data file should be loaded?