Class: Corraios::Containers::Envelope
- Inherits:
-
Base
- Object
- Base
- Corraios::Containers::Envelope
show all
- Defined in:
- lib/corraios/containers/envelope.rb
Instance Method Summary
collapse
Methods inherited from Base
add_attribute, #attributes_names, attributes_restrictions, floor_for, #format, #initialize, #is_a?, minimum_value_for, query_attribute_name, query_attribute_names, set_format, #to_query_params, valid_field?, valid_fields?
Instance Method Details
#can_merge?(envelope) ⇒ Boolean
15
16
17
18
19
|
# File 'lib/corraios/containers/envelope.rb', line 15
def can_merge?(envelope)
new_weight = self.weight + envelope.weight
self.class.valid_field? :weight, new_weight
end
|
#merge!(other) ⇒ Object
21
22
23
24
|
# File 'lib/corraios/containers/envelope.rb', line 21
def merge!(other)
self.weight += other.weight
end
|
#to_package ⇒ Object
26
27
28
|
# File 'lib/corraios/containers/envelope.rb', line 26
def to_package
Package.new weight: self.weight, height: 2, width: self.width, length: self.length
end
|
#valid? ⇒ Boolean
11
12
13
|
# File 'lib/corraios/containers/envelope.rb', line 11
def valid?
self.class.valid_fields? @attributes
end
|