Class: HumanName
- Inherits:
-
Object
- Object
- HumanName
- Defined in:
- lib/human_name.rb,
lib/human_name/methods.rb,
lib/human_name/version.rb,
lib/human_name/defaults.rb
Defined Under Namespace
Classes: Methods
Constant Summary collapse
- VERSION =
"0.1.0".freeze
- Defaults =
HumanName::Methods.new
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.
8 9 10 |
# File 'lib/human_name.rb', line 8 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.
7 8 9 |
# File 'lib/human_name.rb', line 7 def first_name @first_name end |
#last_name ⇒ Object (readonly)
Returns the value of attribute last_name.
7 8 9 |
# File 'lib/human_name.rb', line 7 def last_name @last_name end |
Instance Method Details
#full_name ⇒ Object
20 21 22 |
# File 'lib/human_name.rb', line 20 def full_name non_blank_names.join(' ') end |
#name_initials ⇒ Object
24 25 26 |
# File 'lib/human_name.rb', line 24 def name_initials non_blank_names.map { |n| "#{n[0]}." }.join(' ') end |