Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

mcls/human_name

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages