Sha256: 51ccb630ca92458c817d51795e89b33a787d0cecc4d6251faff2a80f757ccd69

Contents?: true

Size: 641 Bytes

Versions: 2

Compression:

Stored size: 641 Bytes

Contents

module Gendered
  class NameList
    include Enumerable

    attr_reader :names

    def initialize(values)
      @names = Array(values).collect do |value|
        case value
        when String then Name.new(value)
        when Name then value
        end
      end
    end

    def guess!(country_id = nil)
      names.each_slice(100).each do |slice|
        Guesser.new(slice).guess!(country_id)
      end
      names.collect(&:gender)
    end

    def each(&block)
      names.each do |name|
        block.call name
      end
    end

    def [](value)
      names.find do |name|
        name.value == value
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gendered-0.0.7 lib/gendered/name_list.rb
gendered-0.0.5 lib/gendered/name_list.rb