Class: C2eCore::Drops::OrderRecipeFlatDrop

Inherits:
BaseDrop
  • Object
show all
Includes:
Helpers::OrderConversions
Defined in:
/build/app/mailers/c2e_core/drops/order_recipe_flat_drop.rb

Instance Method Summary collapse

Methods included from Helpers::OrderConversions

#converted_price, #format_price

Constructor Details

#initialize(order_recipe_flat_hash, order) ⇒ OrderRecipeFlatDrop

Returns a new instance of OrderRecipeFlatDrop.



8
9
10
11
12
# File '/build/app/mailers/c2e_core/drops/order_recipe_flat_drop.rb', line 8

def initialize(order_recipe_flat_hash, order)
  super()
  @order_recipe_flat_hash = OpenStruct.new order_recipe_flat_hash
  @order = order
end

Instance Method Details

#cover_priceFloat

Returns - Total price recipe covers converted into order’s currency. E.g.: 20.

Returns:

  • (Float)
    • Total price recipe covers converted into order’s currency. E.g.: 20



36
37
38
# File '/build/app/mailers/c2e_core/drops/order_recipe_flat_drop.rb', line 36

def cover_price
  converted_price @order_recipe_flat_hash.cover_price
end

#coversArray[OrderRecipeDrop]

Returns - Returns an array of cover order recipes for order recipe flat.

Returns:

  • (Array[OrderRecipeDrop])
    • Returns an array of cover order recipes for order recipe flat.



47
48
49
# File '/build/app/mailers/c2e_core/drops/order_recipe_flat_drop.rb', line 47

def covers
  @order_recipe_flat_hash.covers.map { |cover| OrderRecipeDrop.new cover, @order }
end

#noteString

Returns - Customers note for recipe. If not present, empty string is returned.

Returns:

  • (String)
    • Customers note for recipe. If not present, empty string is returned.



52
53
54
# File '/build/app/mailers/c2e_core/drops/order_recipe_flat_drop.rb', line 52

def note
  @order_recipe_flat_hash.note
end

#priceFloat

Returns - Unit price of recipe converted into order’s currency. E.g.: 78.

Returns:

  • (Float)
    • Unit price of recipe converted into order’s currency. E.g.: 78



25
26
27
# File '/build/app/mailers/c2e_core/drops/order_recipe_flat_drop.rb', line 25

def price
  converted_price @order_recipe_flat_hash.price
end

#quantityInteger

Returns - count of current recipe in order. E.g.: 2.

Returns:

  • (Integer)
    • count of current recipe in order. E.g.: 2



20
21
22
# File '/build/app/mailers/c2e_core/drops/order_recipe_flat_drop.rb', line 20

def quantity
  @order_recipe_flat_hash.quantity
end

#recipeRecipeDrop

Returns - Returns recipe for order recipe flat as drop object.

Returns:

  • (RecipeDrop)
    • Returns recipe for order recipe flat as drop object.



15
16
17
# File '/build/app/mailers/c2e_core/drops/order_recipe_flat_drop.rb', line 15

def recipe
  RecipeDrop.new @order_recipe_flat_hash.recipe
end

#side_dishesArray[OrderRecipeDrop]

Returns - Returns an array of side dish order recipes for order recipe flat.

Returns:

  • (Array[OrderRecipeDrop])
    • Returns an array of side dish order recipes for order recipe flat.



41
42
43
44
# File '/build/app/mailers/c2e_core/drops/order_recipe_flat_drop.rb', line 41

def side_dishes
  @order_recipe_flat_hash.children_without_covers_sorted
    .map { |order_recipe| OrderRecipeDrop.new order_recipe, @order }
end

#total_priceFloat

Returns - Total price of recipe including covers and side dishes converted into order’s currency. E.g.: 130.

Returns:

  • (Float)
    • Total price of recipe including covers and side dishes converted into order’s currency.

    E.g.: 130



31
32
33
# File '/build/app/mailers/c2e_core/drops/order_recipe_flat_drop.rb', line 31

def total_price
  converted_price @order_recipe_flat_hash.total_price
end