Class: Asdawqw::Phone

Inherits:
BaseModel show all
Defined in:
lib/asdawqw/models/phone.rb

Overview

Phone Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

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_codeString

Country code prefix in phone number. For example “+1”.

Returns:



11
12
13
# File 'lib/asdawqw/models/phone.rb', line 11

def country_code
  @country_code
end

#numberString

Phone number

Returns:



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

.namesObject

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