Class: Etapper::Phone

Inherits:
Object
  • Object
show all
Includes:
Hashable
Defined in:
lib/etapper/classes/phone.rb

Constant Summary collapse

TYPES =
[
:voice,
:mobile,
:pager,
:fax,
:business,
:home
]

Instance Method Summary collapse

Methods included from Hashable

#append_to_hash, #to_hash

Constructor Details

#initialize(params = {}) ⇒ Phone

Returns a new instance of Phone.



16
17
18
19
20
21
22
23
24
# File 'lib/etapper/classes/phone.rb', line 16

def initialize(params = {})
  if params.kind_of?(Etapper::API::Phone)  # Simply wrap the API object we're given
    @base = params
  else
    raise Etapper::BadValueError, "You must supply a valid type!" unless TYPES.include?(params[:type])
    raise Etapper::BadValueError, "You must supply a phone number!" unless params[:number]
    @base = Etapper::API::Phone.new(params[:number], params[:type].titleize)
  end
end

Instance Method Details

#baseObject



26
27
28
# File 'lib/etapper/classes/phone.rb', line 26

def base
  @base
end

#numberObject Also known as: value



38
39
40
# File 'lib/etapper/classes/phone.rb', line 38

def number
  @base.number
end

#number=(val) ⇒ Object Also known as: value=



42
43
44
# File 'lib/etapper/classes/phone.rb', line 42

def number=(val)
  @base.number = val
end

#typeObject Also known as: key



30
31
32
# File 'lib/etapper/classes/phone.rb', line 30

def type
  @base.type.symbolize
end

#type=(val) ⇒ Object Also known as: key=



34
35
36
# File 'lib/etapper/classes/phone.rb', line 34

def type=(val)
  @base.type = val.titleize
end