Class: SBF::Client::Phone

Inherits:
BaseEntity show all
Defined in:
lib/stbaldricks/entities/lib/phone.rb

Defined Under Namespace

Modules: Type

Constant Summary

Constants inherited from BaseEntity

BaseEntity::ELSE

Instance Attribute Summary collapse

Attributes inherited from BaseEntity

#errors

Instance Method Summary collapse

Methods inherited from BaseEntity

allow_instantiation?, attr_accessor, attr_reader, attr_writer, collection_attributes, defined_attributes, #destroyed?, #dirty_data, entity_attr_accessor, entity_attr_reader, entity_attr_writer, entity_attributes, entity_collection_attr_accessor, entity_collection_attr_reader, entity_collection_attr_writer, #error, inherited, #initialize, #keys_hash, #model_name, multitype_attr_accessor, multitype_attr_reader, multitype_attr_writer, multitype_collection_attr_accessor, multitype_collection_attr_reader, multitype_collection_attr_writer, #not_provided_attributes, optional_attributes, #persisted?, #reload!, #reload_recursive, #rollback!, #to_hash, #to_json, #to_partial

Methods included from EntityResponseConcern

#add_errors, #data, #error?, #errors?, #errors_http_code=, #http_code, #success?

Constructor Details

This class inherits a constructor from SBF::Client::BaseEntity

Instance Attribute Details

#extensionObject

Returns the value of attribute extension.



13
14
15
# File 'lib/stbaldricks/entities/lib/phone.rb', line 13

def extension
  @extension
end

#numberObject

Returns the value of attribute number.



13
14
15
# File 'lib/stbaldricks/entities/lib/phone.rb', line 13

def number
  @number
end

#typeObject

Returns the value of attribute type.



12
13
14
# File 'lib/stbaldricks/entities/lib/phone.rb', line 12

def type
  @type
end

Instance Method Details

#format_hrefObject

(402)555-5555 –> tel:4025555555



16
17
18
19
20
# File 'lib/stbaldricks/entities/lib/phone.rb', line 16

def format_href
  return 'tel:' + number.gsub(/\D/, '') unless number.nil?

  number
end

#format_numberObject

This kinda handles extensions, at least? We never actually populate :extension, do we? (402)555-5555 ext. 5555 –> 402.555.555 x5555



24
25
26
27
28
# File 'lib/stbaldricks/entities/lib/phone.rb', line 24

def format_number
  return number.gsub(/\D/, '').gsub(/(\d{3})(\d{3})(\d{4})(\d*)/, '\1.\2.\3 x\4').gsub(/x$/, '').rstrip unless number.nil?

  number
end