Class: Corraios::Containers::Roll
- Inherits:
-
Base
- Object
- Base
- Corraios::Containers::Roll
show all
- Defined in:
- lib/corraios/containers/roll.rb
Class Method Summary
collapse
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?
Class Method Details
.valid_fields?(attributes) ⇒ Boolean
33
34
35
36
|
# File 'lib/corraios/containers/roll.rb', line 33
def valid_fields?(attributes)
super(attributes) &&
(attributes[:diameter] * 2 + attributes[:length]) <= 200.0
end
|
Instance Method Details
#can_merge?(other) ⇒ Boolean
15
16
17
|
# File 'lib/corraios/containers/roll.rb', line 15
def can_merge?(other)
false
end
|
#merge!(other) ⇒ Object
19
20
21
|
# File 'lib/corraios/containers/roll.rb', line 19
def merge!(other)
raise NotImplementedError
end
|
#to_package ⇒ Object
27
28
29
|
# File 'lib/corraios/containers/roll.rb', line 27
def to_package
Package.new weight: self.weight, length: self.length, width: self.diameter, height: self.diameter
end
|
#valid? ⇒ Boolean
11
12
13
|
# File 'lib/corraios/containers/roll.rb', line 11
def valid?
self.class.valid_fields? @attributes
end
|
#volume ⇒ Object
23
24
25
|
# File 'lib/corraios/containers/roll.rb', line 23
def volume
3.1415 * (diameter/2)**2 * length
end
|