Sha256: 11b8dab407cc2fd2db164afe968f1105a8e4b8fdd6fa3ab77e237110085dd90a

Contents?: true

Size: 521 Bytes

Versions: 7

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

7 entries across 7 versions & 1 rubygems

Version Path
bright-1.3 lib/bright/phone_number.rb
bright-1.2.3 lib/bright/phone_number.rb
bright-1.2.2 lib/bright/phone_number.rb
bright-1.2.1 lib/bright/phone_number.rb
bright-1.2 lib/bright/phone_number.rb
bright-1.1 lib/bright/phone_number.rb
bright-1.0 lib/bright/phone_number.rb