Class: Factorix::API::Category

Inherits:
Data
  • Object
show all
Defined in:
lib/factorix/api/category.rb,
lib/factorix/api/category.rb,
sig/factorix/api/category.rbs

Overview

Category object from MOD Portal API

Represents a MOD category with value, name, and description. Uses flyweight pattern - same category value returns same instance.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#description ⇒ String (readonly)

Returns category description.

Returns:

  • (String) —

    category description



14
15
16
# File 'lib/factorix/api/category.rb', line 14

def description
  @description
end

#name ⇒ String (readonly)

Returns human-readable category name (e.g., "Content", "Utilities").

Returns:

  • (String) —

    human-readable category name (e.g., "Content", "Utilities")



14
15
16
# File 'lib/factorix/api/category.rb', line 14

def name
  @name
end

#value ⇒ String (readonly)

Returns category value (e.g., "content", "utilities", "" for no category).

Returns:

  • (String) —

    category value (e.g., "content", "utilities", "" for no category)



14
15
16
# File 'lib/factorix/api/category.rb', line 14

def value
  @value
end

Class Method Details

.for(value) ⇒ Category

Get Category instance for the given value

Returns predefined instance for known categories (flyweight pattern). Raises an error for unknown category values.

Parameters:

  • value (String) —

    category value

Returns:

Raises:

  • (KeyError) —

    if category value is unknown



67
# File 'lib/factorix/api/category.rb', line 67

def self.for(value) = CATEGORIES.fetch(value.to_s)

.identifiers ⇒ Array<String>

Returns all category identifiers.

Returns:

  • (Array<String>) —

    all category identifiers



57
# File 'lib/factorix/api/category.rb', line 57

def self.identifiers = CATEGORIES.keys