Class: HumanName

Inherits:
Object
  • Object
show all
Defined in:
lib/human_name.rb,
lib/human_name/methods.rb,
lib/human_name/version.rb

Defined Under Namespace

Classes: Methods

Constant Summary collapse

VERSION =
"0.0.1".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(first_name, last_name) ⇒ HumanName

Returns a new instance of HumanName.



7
8
9
# File 'lib/human_name.rb', line 7

def initialize(first_name, last_name)
  @first_name, @last_name = first_name, last_name
end

Instance Attribute Details

#first_nameObject (readonly)

Returns the value of attribute first_name.



6
7
8
# File 'lib/human_name.rb', line 6

def first_name
  @first_name
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



6
7
8
# File 'lib/human_name.rb', line 6

def last_name
  @last_name
end

Instance Method Details

#full_nameObject



19
20
21
# File 'lib/human_name.rb', line 19

def full_name
  non_blank_names.join(' ')
end

#name_initialsObject



23
24
25
# File 'lib/human_name.rb', line 23

def name_initials
  non_blank_names.map { |n| "#{n[0]}." }.join(' ')
end