Class: CraftingTable::Recipe

Inherits:
Object
  • Object
show all
Defined in:
lib/crafting_table/recipe.rb

Overview

A class representing a single recipe. A recipe has a name, one to n inputs, and one to n outputs.

Since:

  • 0.2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, input, output) ⇒ Recipe

Create a new recipe.

Examples:

Torch

recipe = Recipe.new('Torch',
                    { Item.new('Coal', 263, 0) => 1,
                      Item.new('Stick', 280, 0) => 1 },
                    { Item.new('Torch', 50, 0) => 4 })

Parameters:

  • name (String)

    The recipe’s name

  • input (Hash{Item => Integer})

    A hash of items and their amounts which are required to craft the recipe.

  • output (Hash{Item => Integer})

    A hash of items and their amounts which you get when crafting the recipe.

Since:

  • 0.2



28
29
30
# File 'lib/crafting_table/recipe.rb', line 28

def initialize(name, input, output)
  @name, @input, @output = name, input, output
end

Instance Attribute Details

#inputObject (readonly)

Since:

  • 0.2



11
12
13
# File 'lib/crafting_table/recipe.rb', line 11

def input
  @input
end

#nameObject (readonly)

Since:

  • 0.2



11
12
13
# File 'lib/crafting_table/recipe.rb', line 11

def name
  @name
end

#outputObject (readonly)

Since:

  • 0.2



11
12
13
# File 'lib/crafting_table/recipe.rb', line 11

def output
  @output
end