Class: Ryba::Name

Inherits:
Object
  • Object
show all
Defined in:
lib/ryba/name.rb

Class Method Summary collapse

Class Method Details

.family_name(male = nil) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ryba/name.rb', line 19

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

  famname = Ryba.pick(Data::FamilyNames)

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

.first_name(male = nil) ⇒ Object



11
12
13
# File 'lib/ryba/name.rb', line 11

def first_name(male = nil)
  pick_with_gender(male, Data::MaleNames, Data::FemaleNames)
end

.full_name(male = nil) ⇒ Object



31
32
33
34
35
# File 'lib/ryba/name.rb', line 31

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

  "#{family_name(male)} #{first_name(male)} #{middle_name(male)}"
end

.gender {|male| ... } ⇒ Object

Yields:

  • (male)


5
6
7
8
9
# File 'lib/ryba/name.rb', line 5

def gender
  male = Kernel.rand(100) < 50
  yield(male) if block_given?
  male
end

.middle_name(male = nil) ⇒ Object



15
16
17
# File 'lib/ryba/name.rb', line 15

def middle_name(male = nil)
  pick_with_gender(male, Data::MaleMiddleNames, Data::FemaleMiddleNames)
end