Project

human_name

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
If I have to write 'def full_name' one more time...
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
>= 0
>= 0
 Project Readme

HumanName

Gem Version Build Status

Never write def full_name again!

Installation

Add this line to your application's Gemfile:

gem 'human_name'

And then execute:

$ bundle

Or install it yourself as:

$ gem install human_name

Usage

require "rubygems"
require "human_name"

class Person
  # Assumes :first_name and :last_name methods exist
  include HumanName::Defaults

  attr_reader :first_name, :last_name

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

person = Person.new("John", "Doe")
p person.human_name     # => #<HumanName:0x007fe590825b68 @first_name="John", @last_name="Doe">
p person.full_name      # => "John Doe"
p person.name_initials  # => "J. D."

class P3rs0n
  # You can also use custom methods
  include HumanName::Methods.new(:f_n4m3, :l_n4m3)

  def f_n4m3
    "John"
  end

  def l_n4m3
    "Doe"
  end
end

person = P3rs0n.new
p person.human_name     # => #<HumanName:0x007fe590825b68 @first_name="John", @last_name="Doe">
p person.full_name      # => "John Doe"
p person.name_initials  # => "J. D."
p person.human_name.first_name  # => "John"
p person.human_name.last_name   # => "Doe"

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request