Class: Corraios::Delivery
- Inherits:
-
Object
- Object
- Corraios::Delivery
- Defined in:
- lib/corraios/delivery.rb
Instance Attribute Summary collapse
-
#amount_of_posts ⇒ Object
readonly
Returns the value of attribute amount_of_posts.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#deadline ⇒ Object
readonly
Returns the value of attribute deadline.
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #error? ⇒ Boolean
-
#initialize(correios_response, service_name, service_code) ⇒ Delivery
constructor
A new instance of Delivery.
- #merge!(other) ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(correios_response, service_name, service_code) ⇒ Delivery
Returns a new instance of Delivery.
9 10 11 12 13 14 |
# File 'lib/corraios/delivery.rb', line 9 def initialize(correios_response, service_name, service_code) @name = service_name @code = service_code @amount_of_posts = 1 parse_response(correios_response) end |
Instance Attribute Details
#amount_of_posts ⇒ Object (readonly)
Returns the value of attribute amount_of_posts.
7 8 9 |
# File 'lib/corraios/delivery.rb', line 7 def amount_of_posts @amount_of_posts end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
4 5 6 |
# File 'lib/corraios/delivery.rb', line 4 def code @code end |
#deadline ⇒ Object (readonly)
Returns the value of attribute deadline.
5 6 7 |
# File 'lib/corraios/delivery.rb', line 5 def deadline @deadline end |
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
5 6 7 |
# File 'lib/corraios/delivery.rb', line 5 def @error_message end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/corraios/delivery.rb', line 4 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/corraios/delivery.rb', line 5 def value @value end |
Instance Method Details
#==(other) ⇒ Object
33 34 35 |
# File 'lib/corraios/delivery.rb', line 33 def ==(other) @code == other.code end |
#error? ⇒ Boolean
16 17 18 |
# File 'lib/corraios/delivery.rb', line 16 def error? !!@error_message end |
#merge!(other) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/corraios/delivery.rb', line 24 def merge!(other) raise CorraiosError unless self == other if success? && other.success? merge_when_success!(other) else merge_when_error!(other) end end |
#success? ⇒ Boolean
20 21 22 |
# File 'lib/corraios/delivery.rb', line 20 def success? !error? end |