Sha256: 8c6e2308a4c433eff832e498af5455bc8df1df67d53d6bc73457c9c94bdaaaf0

Contents?: true

Size: 521 Bytes

Versions: 1

Compression:

Stored size: 521 Bytes

Contents

module Bright
  class PhoneNumber < Model
    @attribute_names = [:phone_number, :extension, :type]
    attr_accessor(*@attribute_names)
    TYPES = ["Cell", "Home", "Work", "Other"]

    def phone_number=(number)
      number_a = number.to_s.split(/x|X/)
      if number_a.size == 2
        @extension = number_a.last.gsub(/[^0-9]/, "").strip
      end
      @phone_number = number_a.first.gsub(/[^0-9]/, "").strip
    end

    def extension=(number)
      @extension = number.gsub(/[^0-9]/, "").strip
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bright-2.0 lib/bright/phone_number.rb