Sha256: e014be66a0a9d5332d908832b1e12466f1abac328b26650df07fa094314778d6

Contents?: true

Size: 517 Bytes

Versions: 2

Compression:

Stored size: 517 Bytes

Contents

class PhoneNumber < ActiveRecord::Base
  belongs_to :vcard
  belongs_to :object, :polymorphic => true

  validates_presence_of :number

  def label
    case phone_number_type
    when 'phone'
      "Tel:"
    when 'fax'
      "Fax:"
    when 'mobile'
      "Mob:"
    when 'email'
      "Mail:"
    else
      ""
    end
  end
  
  def to_s(separator = " ", format = :default)
    case format
      when :label
        return [label, number].compact.join(separator)
      else
        return number
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
has_vcards-0.10.0 app/models/phone_number.rb
has_vcards-0.9.0 app/models/phone_number.rb