Variable API Reference
Variables are special simple Items that hold configuration values like environment settings or default paths. They have a Key (e.g. $HOME, $PATH, $USER) and a Value (e.g. /home/user, /usr/bin:/bin, user).
API Documentation
hands_scaphoid.objects.VariableItem
Classes
VariableItem
Bases: ItemCore
Represents a variable in the shell context.
Attributes:
| Name |
Type |
Description |
name |
str
|
The name of the variable.
|
value |
str
|
The value of the variable.
|
Source code in src/hands_scaphoid/objects/VariableItem.py
| class VariableItem(ItemCore):
"""
Represents a variable in the shell context.
Attributes:
name (str): The name of the variable.
value (str): The value of the variable.
"""
def __init__(self, name: str, value: str):
"""Initializes a VariableItem instance."""
super().__init__(name, value, item_type=ItemType.VARIABLE)
self.value = value
def __repr__(self):
"""Returns a string representation of the VariableItem."""
return f"VariableItem(name={self.name}, value={self.value})"
@classmethod
def from_dict(cls, data: dict) -> "VariableItem":
"""ensure correct type"""
obj = super().from_dict(data)
if not is_instance(obj, VariableItem):
raise TypeError(f"from_dict expected to create 'VariableItem', got '{type(obj)}'")
return obj
|
Functions
__init__(name, value)
Initializes a VariableItem instance.
Source code in src/hands_scaphoid/objects/VariableItem.py
| def __init__(self, name: str, value: str):
"""Initializes a VariableItem instance."""
super().__init__(name, value, item_type=ItemType.VARIABLE)
self.value = value
|
__repr__()
Returns a string representation of the VariableItem.
Source code in src/hands_scaphoid/objects/VariableItem.py
| def __repr__(self):
"""Returns a string representation of the VariableItem."""
return f"VariableItem(name={self.name}, value={self.value})"
|
from_dict(data)
classmethod
ensure correct type
Source code in src/hands_scaphoid/objects/VariableItem.py
| @classmethod
def from_dict(cls, data: dict) -> "VariableItem":
"""ensure correct type"""
obj = super().from_dict(data)
if not is_instance(obj, VariableItem):
raise TypeError(f"from_dict expected to create 'VariableItem', got '{type(obj)}'")
return obj
|