Class: PagSeguro::Shipping

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/pag_seguro/shipping.rb

Constant Summary collapse

PAC =
1
SEDEX =
2
UNIDENTIFIED =
3

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Shipping

Returns a new instance of Shipping.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pag_seguro/shipping.rb', line 14

def initialize(attributes = {})
  @type = attributes[:type] || UNIDENTIFIED
  @state = attributes[:state]
  @city = attributes[:city]
  @postal_code = attributes[:postal_code]
  @district = attributes[:district]
  @street = attributes[:street]
  @number = attributes[:number]
  @complement = attributes[:complement]
  @cost = attributes[:cost]
end

Instance Attribute Details

#cityObject

Returns the value of attribute city.



11
12
13
# File 'lib/pag_seguro/shipping.rb', line 11

def city
  @city
end

#complementObject

Returns the value of attribute complement.



11
12
13
# File 'lib/pag_seguro/shipping.rb', line 11

def complement
  @complement
end

#costObject

Returns the value of attribute cost.



11
12
13
# File 'lib/pag_seguro/shipping.rb', line 11

def cost
  @cost
end

#districtObject

Returns the value of attribute district.



11
12
13
# File 'lib/pag_seguro/shipping.rb', line 11

def district
  @district
end

#numberObject

Returns the value of attribute number.



11
12
13
# File 'lib/pag_seguro/shipping.rb', line 11

def number
  @number
end

#postal_codeObject

Returns the value of attribute postal_code.



11
12
13
# File 'lib/pag_seguro/shipping.rb', line 11

def postal_code
  @postal_code
end

#stateObject

Returns the value of attribute state.



11
12
13
# File 'lib/pag_seguro/shipping.rb', line 11

def state
  @state
end

#streetObject

Returns the value of attribute street.



11
12
13
# File 'lib/pag_seguro/shipping.rb', line 11

def street
  @street
end

#typeObject

Returns the value of attribute type.



11
12
13
# File 'lib/pag_seguro/shipping.rb', line 11

def type
  @type
end

Instance Method Details

#pac?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/pag_seguro/shipping.rb', line 34

def pac?
  PAC == type
end

#sedex?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/pag_seguro/shipping.rb', line 38

def sedex?
  SEDEX == type
end

#unidentified?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/pag_seguro/shipping.rb', line 42

def unidentified?
  UNIDENTIFIED == type
end