Sha256: 00af1bbfe85274994519dcb3cbce668d39e5a5be718f67ae5b8b6b470a6a18e1

Contents?: true

Size: 689 Bytes

Versions: 2

Compression:

Stored size: 689 Bytes

Contents

module Juscribe
  class Name
    attr_reader :first, :middle, :last

    class << self
      def convert(input)
        case input
        when String
          new(*input.split(/\s+/))
        end
      end
    end

    def initialize(first, *others, last)
      @first, @middle, @last = first, others.first, last
    end

    def middle_initial
      "#{middle.first}." if middle.present?
    end

    def first_and_last
      [first, *last].join(' ')
    end

    def full
      [first, *middle_initial, *last].join(' ')
    end

    def complete
      [first, *middle, *last].join(' ')
    end

    def to_s
      full
    end

    def inspect
      %Q{"#{complete}"}
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
personhood-0.2.0 lib/juscribe/name.rb
personhood-0.1.2 lib/juscribe/name.rb