gender_detector icon indicating copy to clipboard operation
gender_detector copied to clipboard

Add class method shortcuts

Open hollingberry opened this issue 11 years ago • 1 comments

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.

hollingberry avatar Nov 18 '14 01:11 hollingberry

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?

bmuller avatar Mar 21 '15 00:03 bmuller