Sha256: ac04a1710ea57adb787cf2294b7394246f8a1a8adb418400fbdbbff67fb95d76

Contents?: true

Size: 880 Bytes

Versions: 1

Compression:

Stored size: 880 Bytes

Contents

module Ryba
  class Name
    class <<self
      def gender
        male = Kernel.rand(100) < 50
        yield(male) if block_given?
        male
      end

      def first_name(male = nil)
        pick_with_gender(male, Ryba::Data::MaleNames, Ryba::Data::FemaleNames)
      end
      
      def middle_name(male = nil)
        pick_with_gender(male, Ryba::Data::MaleMiddleNames, Ryba::Data::FemaleMiddleNames)
      end

      def family_name(male = nil)
        male = gender if male.nil?

        famname = Ryba.pick(Ryba::Data::FamilyNames)

        if famname.is_a? Array
          famname[0] + famname[male ? 1 : 2]
        else
          male ? famname : famname + 'а'
        end
      end

      private

      def pick_with_gender(male, male_ary, female_ary)
        male = gender if male.nil?
        Ryba.pick(male ? male_ary : female_ary)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
be9-ryba-0.0.2 lib/ryba/name.rb