Class: Corraios::Containers::Roll

Inherits:
Base
  • Object
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?, valid_field?

Constructor Details

This class inherits a constructor from Corraios::Containers::Base

Class Method Details

.valid_fields?(attributes) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
37
# File 'lib/corraios/containers/roll.rb', line 34

def valid_fields?(attributes)
  super(attributes) &&
    (attributes[:diameter] * 2 + attributes[:length]) <= 200.0
end

Instance Method Details

#can_merge?(other) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/corraios/containers/roll.rb', line 11

def can_merge?(other)
  false
end

#merge!(other) ⇒ Object

Raises:

  • (NotImplementedError)


15
16
17
# File 'lib/corraios/containers/roll.rb', line 15

def merge!(other)
  raise NotImplementedError
end

#to_packageObject



23
24
25
26
27
28
29
30
# File 'lib/corraios/containers/roll.rb', line 23

def to_package
  Package.new(
    weight: self.weight,
    height: Package::floor_for(:height, self.diameter),
    width: Package::floor_for(:width, self.diameter),
    length: Package::floor_for(:length, self.length)
  )
end

#volumeObject



19
20
21
# File 'lib/corraios/containers/roll.rb', line 19

def volume
  3.1415 * (diameter/2)**2 * length
end