Skip to contents

Standardized taxonomy for classifying recipes by domain. Supports hierarchical categories with parent-child relationships.

Value

An R6 object of class RecipeCategory.

Public fields

name

Character. Category identifier.

description

Character. Human-readable description.

parent

RecipeCategory or NULL. Parent category for hierarchy.

Methods


RecipeCategory$new()

Create a new RecipeCategory

Usage

RecipeCategory$new(name, description, parent = NULL)

Arguments

name

Character. Category identifier (non-empty string).

description

Character. Description of the category.

parent

RecipeCategory or NULL. Parent category.


RecipeCategory$is_subcategory_of()

Check if this category is a subcategory of another

Usage

RecipeCategory$is_subcategory_of(ancestor_name)

Arguments

ancestor_name

Character. Name of the potential ancestor category.

Returns

Logical


RecipeCategory$get_path()

Get full hierarchical path

Usage

RecipeCategory$get_path()

Returns

Character string with slash-separated path


RecipeCategory$equals()

Check equality by name

Usage

RecipeCategory$equals(other)

Arguments

other

RecipeCategory to compare with.

Returns

Logical


RecipeCategory$to_list()

Serialize to list for JSON

Usage

RecipeCategory$to_list()

Returns

List representation


RecipeCategory$print()

Print category

Usage

RecipeCategory$print(...)

Arguments

...

Additional arguments (not used)


RecipeCategory$from_list()

Deserialize a RecipeCategory from a list

Usage

RecipeCategory$from_list(lst)

Arguments

lst

List with name, description, parent fields, or NULL

Returns

RecipeCategory object or NULL


RecipeCategory$clone()

The objects of this class are cloneable with this method.

Usage

RecipeCategory$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Use recipe_category() for the public API:
cat <- recipe_category(
  "economics", "Economic indicators"
)
sub <- recipe_category(
  "labor_market", "Labor market",
  parent = "economics"
)