Class: SBF::Client::Phone
- Inherits:
-
BaseEntity
- Object
- BaseEntity
- SBF::Client::Phone
- Defined in:
- lib/stbaldricks/entities/lib/phone.rb
Defined Under Namespace
Modules: Type
Constant Summary
Constants inherited from BaseEntity
Instance Attribute Summary collapse
-
#extension ⇒ Object
Returns the value of attribute extension.
-
#number ⇒ Object
Returns the value of attribute number.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from BaseEntity
Instance Method Summary collapse
-
#format_href ⇒ Object
(402)555-5555 –> tel:4025555555.
-
#format_number ⇒ Object
This kinda handles extensions, at least? We never actually populate :extension, do we? (402)555-5555 ext.
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
#extension ⇒ Object
Returns the value of attribute extension.
13 14 15 |
# File 'lib/stbaldricks/entities/lib/phone.rb', line 13 def extension @extension end |
#number ⇒ Object
Returns the value of attribute number.
13 14 15 |
# File 'lib/stbaldricks/entities/lib/phone.rb', line 13 def number @number end |
#type ⇒ Object
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_href ⇒ Object
(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_number ⇒ Object
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 |