Class: HumanName
- Inherits:
-
Object
- Object
- HumanName
- 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
-
#first_name ⇒ Object
readonly
Returns the value of attribute first_name.
-
#last_name ⇒ Object
readonly
Returns the value of attribute last_name.
Instance Method Summary collapse
- #full_name ⇒ Object
-
#initialize(first_name, last_name) ⇒ HumanName
constructor
A new instance of HumanName.
- #name_initials ⇒ Object
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_name ⇒ Object (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_name ⇒ Object (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_name ⇒ Object
19 20 21 |
# File 'lib/human_name.rb', line 19 def full_name non_blank_names.join(' ') end |
#name_initials ⇒ Object
23 24 25 |
# File 'lib/human_name.rb', line 23 def name_initials non_blank_names.map { |n| "#{n[0]}." }.join(' ') end |