Class: Asdawqw::Phone
- Defined in:
- lib/asdawqw/models/phone.rb
Overview
Phone Model.
Instance Attribute Summary collapse
-
#country_code ⇒ String
Country code prefix in phone number.
-
#number ⇒ String
Phone number.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#initialize(country_code = nil, number = nil) ⇒ Phone
constructor
A new instance of Phone.
Methods inherited from BaseModel
Constructor Details
#initialize(country_code = nil, number = nil) ⇒ Phone
Returns a new instance of Phone.
25 26 27 28 29 |
# File 'lib/asdawqw/models/phone.rb', line 25 def initialize(country_code = nil, number = nil) @country_code = country_code @number = number end |
Instance Attribute Details
#country_code ⇒ String
Country code prefix in phone number. For example “+1”.
11 12 13 |
# File 'lib/asdawqw/models/phone.rb', line 11 def country_code @country_code end |
#number ⇒ String
Phone number
15 16 17 |
# File 'lib/asdawqw/models/phone.rb', line 15 def number @number end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/asdawqw/models/phone.rb', line 32 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. country_code = hash['countryCode'] number = hash['number'] # Create object from extracted values. Phone.new(country_code, number) end |
.names ⇒ Object
A mapping from model property names to API property names.
18 19 20 21 22 23 |
# File 'lib/asdawqw/models/phone.rb', line 18 def self.names @_hash = {} if @_hash.nil? @_hash['country_code'] = 'countryCode' @_hash['number'] = 'number' @_hash end |