Class: HasVcards::PhoneNumber
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- HasVcards::PhoneNumber
- Defined in:
- app/models/has_vcards/phone_number.rb
Instance Method Summary collapse
- #label ⇒ Object
-
#to_s(format = :default, separator = ': ') ⇒ Object
String.
-
#to_url ⇒ Object
Generate a contact URL.
Instance Method Details
#label ⇒ Object
32 33 34 35 |
# File 'app/models/has_vcards/phone_number.rb', line 32 def label return '' if phone_number_type.blank? I18n.translate(phone_number_type, scope: 'activerecord.attributes.has_vcards/phone_number.phone_number_type_enum', default: phone_number_type.titleize) end |
#to_s(format = :default, separator = ': ') ⇒ Object
String
38 39 40 41 42 43 44 45 |
# File 'app/models/has_vcards/phone_number.rb', line 38 def to_s(format = :default, separator = ': ') case format when :label return [label, number].compact.join(separator) else return number end end |
#to_url ⇒ Object
Generate a contact URL
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/models/has_vcards/phone_number.rb', line 48 def to_url scheme = case phone_number_type when 'phone' then 'tel' when 'mobile' then 'tel' when 'fax' then 'fax' when 'email' then 'mailto' end return unless scheme "#{scheme}:#{number}" end |