MAGE::...ityUnit(3pm)
β¨ NAME β¨
Bio::MAGE::Measurement::QuantityUnit β bestie, it's a class for the MAGE-OM API. That's the whole vibe. π
okay so quick housekeeping: this page lives in the User Contributed Perl Documentation section, and its manual name is MAGE::...ityUnit(3pm). Slash it into your brain, we move.
π¦ SYNOPSIS π¦
Like, here's how you actually use the thing:
use Bio::MAGE::Measurement::QuantityUnit
# creating an empty instance
my $quantityunit = Bio::MAGE::Measurement::QuantityUnit->new();
# creating an instance with existing data
my $quantityunit = Bio::MAGE::Measurement::QuantityUnit->new(
unitNameCV=>$unitnamecv_val,
unitName=>$unitname_val,
propertySets=>\@namevaluetype_list,
);
# 'unitNameCV' attribute
my $unitNameCV_val = $quantityunit->unitNameCV(); # getter
$quantityunit->unitNameCV($value); # setter
# 'unitName' attribute
my $unitName_val = $quantityunit->unitName(); # getter
$quantityunit->unitName($value); # setter
# 'propertySets' association
my $namevaluetype_array_ref = $quantityunit->propertySets(); # getter
$quantityunit->propertySets(\@namevaluetype_list); # setter
Get it, set it, live your truth. π
πΈ DESCRIPTION πΈ
Straight from the MAGE-OM documentation for the "QuantityUnit" class, and I quote:
Quantity
That's it. That's the description. Iconic minimalism, honestly. π
π§ INHERITANCE π§
Bio::MAGE::Measurement::QuantityUnit has the following superclasses, aka its ancestry, its lineage, its main character bloodline:
Bio::MAGE::Measurement::Unit
So yeah, it inherits stuff. Generational wealth but for methods. π
β¨ CLASS METHODS β¨
lowkey important: every single one of these can be called without an instance first, using the Bio::MAGE::Measurement::QuantityUnit->methodname() syntax. Static-ish. No object required. Slay.
π new()
π new(%args)
The object constructor new() accepts the following optional named-value style arguments:
unitNameCVβ sets the value of the"unitNameCV"attributeunitNameβ sets the value of the"unitName"attribute (fun fact, this attribute was inherited from class"Bio::MAGE::Measurement::Unit")propertySetsβ sets the value of the"propertySets"association (and this one was inherited from class"Bio::MAGE::Extendable")
the value must be of type: array of "Bio::MAGE::NameValueType". No cap, it has to be that exact type. π«Ά
π $obj = class->new(%parameters)
The "new()" method is the class constructor. The one. The origin story.
- Parameters: if you hand it a list of name/value parameters, the corresponding slots, attributes, or associations get their initial values set by the constructor. It just does that for you.
- Return value: it returns a reference to an object of the class. An actual object. Yours. π
- Side effects: it invokes the
"initialize()"method if it's defined by the class. So if your class has aninitialize(), bestie, it's running. Periodt.
π @names = class->get_slot_names()
The "get_slot_names()" method is how you retrieve the name of all slots defined in a given class. All of them. The full roster.
NOTE: the list of names does not include attribute or association names. Read that again, because people get this wrong constantly and then they're in my DMs like "why isn't it here." It's not here. It was never going to be here. π
- Return value: a list of the names of all slots defined for this class.
- Side effects: none. Zero. It's chill like that.
π @name_list = get_attribute_names()
Returns the list of attribute data members for this class. The attribute squad. That's it, that's the whole method.
π @name_list = get_association_names()
Returns the list of association data members for this class. Same energy, different category. π
β @class_list = get_superclasses()
Returns the list of superclasses for this class. The ancestors. The ones who came before. Respect. π
β @class_list = get_subclasses()
Returns the list of subclasses for this class. The descendants. The next generation. They're carrying the legacy. π
π¦ $name = class_name()
Returns the full class name for this class. The whole thing, no abbreviations, no cutting corners.
π¦ $package_name = package_name()
Returns the base package name (i.e. no 'namespace::') of the package that contains this class. So like, just the base. The 'namespace::' part gets left at home. β¨
π %assns = associations()
Returns the association meta-information in a hash where the keys are the association names and the values are "Association" objects that provide the meta-information for the association.
Meta-information about the meta-information. It's giving very inception, very we heard you like info so we put info in your info. And we're obsessed with it. π
and we're still going, bestieβ¦
π INSTANCE METHODS π
πΈ $obj_copy = $obj->new()
okay so when you call new() on an actual object reference instead of on a class name, it turns into a copy constructor β the shiny new object starts out with all the same values as the one you copied. it's giving photocopier but make it β¨fancyβ¨.
- Parameters: literally no input parameters get used here. the initial values just come straight off the object you're copying. no notes.
- Return value: a reference to an object of the class. π«Ά
- Side effects: it invokes the
initialize()method, but only if the class actually defines one.
π $obj->set_slots(%parameters)
π $obj->set_slots(\@name_list, \@value_list)
the set_slots() method is your girl for setting a whole bunch of slots at once. she takes two different invocation styles:
- the first one takes a named parameter list
- the second one takes two array references
- Return value: none (she's a doer, not a talker π )
- Side effects: will call
croak()if you use a slot_name that the class doesn't define. so like, don't.
π¦ @obj_list = $obj->get_slots(@name_list)
the get_slots() method grabs the values of a bunch of slots at the same time. bulk haul, bestie.
- Return value: a list of instance objects
- Side effects: none β¨
π $val = $obj->set_slot($name,$val)
the set_slot() method sets the slot $name to the value $val. iconic behavior honestly.
- Return value: the new value of the slot, i.e.
$val - Side effects: none
π $val = $obj->get_slot($name)
the get_slot() method is used to get the values of a number of slots at the same time. (yes, the description says "a number of slots" even though it hands you back one β we're just relaying the lore fr fr π)
- Return value: a single slot value, or
undefif the slot has not been initialized - Side effects: none
β¨ ATTRIBUTES β¨
Attributes are simple data types that belong to a single instance of a class. In the Perl implementation of the MAGE-OM classes, the interface to attributes is implemented using separate setter and getter methods for each attribute.
Bio::MAGE::Measurement::QuantityUnit has the following attribute accessor methods:
β unitNameCV
Methods for the unitNameCV attribute.
From the MAGE-OM documentation:
π $val = $quantityunit->setUnitNameCV($val)
The restricted setter method for the unitNameCV attribute.
unitNameCV is an enumerated attribute β it can only be set to undef or one of the following values: mol amol fmol pmol nmol umol mmol molecules other
- Input parameters: the value to which the
unitNameCVattribute will be set - Return value: the current value of the
unitNameCVattribute - Side effects: none
- Exceptions: will call
croak()if no input parameters are specified, or if too many input parameters are specified, or if$valis not one of the accepted enumeration values:molamolfmolpmolnmolumolmmolmoleculesother
π $val = $quantityunit->getUnitNameCV()
The restricted getter method for the unitNameCV attribute.
- Input parameters: none
- Return value: the current value of the
unitNameCVattribute : an instance of typemol amol fmol pmol nmol umol mmol molecules other - Side effects: none
- Exceptions: will call
croak()if any input parameters are specified
β unitName
Methods for the unitName attribute.
From the MAGE-OM documentation:
The name of the unit.
π $val = $quantityunit->setUnitName($val)
The restricted setter method for the unitName attribute.
- Input parameters: the value to which the
unitNameattribute will be set - Return value: the current value of the
unitNameattribute - Side effects: none
- Exceptions: will call
croak()if no input parameters are specified, or if too many input parameters are specified
π $val = $quantityunit->getUnitName()
The restricted getter method for the unitName attribute.
- Input parameters: none
- Return value: the current value of the
unitNameattribute - Side effects: none
- Exceptions: will call
croak()if any input parameters are specified
π ASSOCIATIONS π
Associations are references to other classes. Associations in MAGE-OM have a cardinality that determines the minimum and maximum number of instances of the 'other' class that maybe included in the association:
- There must be exactly one item in the association, i.e. this is a mandatory data field.
0..1
There may be one item in the association, i.e. this is an optional data field.
1..N
There must be one or more items in the association, i.e. this is a mandatory data field, with list cardinality.
0..N
There may be one or more items in the association, i.e. this is an optional data field, with list cardinality.
Bio::MAGE::Measurement::QuantityUnit has the following association accessor methods:
π« propertySets
Methods for the propertySets association.
From the MAGE-OM documentation:
Allows specification of name/value pairs. Meant to primarily help in-house, pipeline processing of instances by providing a place for values that aren't part of the specification proper.
π₯ $array_ref = $quantityunit->setPropertySets($array_ref)
The restricted setter method for the propertySets association.
- Input parameters: the value to which the
propertySetsassociation will be set : a reference to an array of objects of typeBio::MAGE::NameValueType - Return value: the current value of the
propertySetsassociation : a reference to an array of objects of typeBio::MAGE::NameValueType - Side effects: none
- Exceptions: will call
croak()if no input parameters are specified, or if too many input parameters are specified, or if$array_refis not a reference to an array classBio::MAGE::NameValueTypeinstances
π₯ $array_ref = $quantityunit->getPropertySets()
The restricted getter method for the propertySets association.
- Input parameters: none
- Return value: the current value of the
propertySetsassociation : a reference to an array of objects of typeBio::MAGE::NameValueType - Side effects: none
- Exceptions: will call
croak()if any input parameters are specified
π₯ $val = $quantityunit->addPropertySets(@vals)
Because the propertySets association has list cardinality, it may store more than one value. This method adds the current list of objects in the propertySets association.
- Input parameters: the list of values
@valsto add to the propertySets association. NOTE: submitting a single value is permitted. - Return value: the number of items stored in the slot after adding
@vals - Side effects: none
- Exceptions: will call
croak()if no input parameters are specified, or if any of the objects in@valsis not an instance of classBio::MAGE::NameValueType
sub initialize {
my $self = shift;
return 1;
}
π§ SLOTS, ATTRIBUTES, AND ASSOCIATIONS π§
In the Perl implementation of MAGE-OM classes, there are three types of class data members: slots, attributes, and associations.
π SLOTS
This API uses the term slot to indicate a data member of the class that was not present in the UML model and is used for mainly internal purposes β use only if you understand the inner workings of the API. Most often slots are used by generic methods such as those in the XML writing and reading classes.
Slots are implemented using unified getter/setter methods:
$var = $obj->slot_name();β Retrieves the current value of the slot.$new_var = $obj->slot_name($new_var);β Store$new_varin the slot - the return value is also$new_var.@names = $obj->get_slot_names()β Returns the list of all slots in the class.
DATA CHECKING: No data type checking is made for these methods.
πΈ ATTRIBUTES AND ASSOCIATIONS
The terms attribute and association indicate data members of the class that were specified directly from the UML model.
In the Perl implementation of MAGE-OM classes, association and attribute accessors are implemented using three separate methods:
get*β Retrieves the current value.
NOTE: For associations, if the association has list cardinality, an array reference is returned.
DATA CHECKING: Ensure that no argument is provided.
set*β Sets the current value, replacing any existing value.
NOTE: For associations, if the association has list cardinality, the argument must be an array reference. Because of this, you probably should be using the add* methods.
DATA CHECKING: For attributes, ensure that a single value is provided as the argument. For associations, if the association has list cardinality, ensure that the argument is a reference to an array of instances of the correct MAGE-OM class, otherwise ensure that there is a single argument of the correct MAGE-OM class.
add*β NOTE: Only present in associations with list cardinality.
Appends a list of objects to any values that may already be stored in the association.
DATA CHECKING: Ensure that all arguments are of the correct MAGE-OM class.
π GENERIC METHODS π
The unified base class of all MAGE-OM classes, Bio::MAGE::Base, provides a set of generic methods that will operate on slots, attributes, and associations:
$val = $obj->get_slot($name)
\@list_ref = $obj->get_slots(@name_list);
$val = $obj->set_slot($name,$val)
$obj->set_slots(%parameters)
$obj->set_slots(\@name_list, \@value_list)
See elsewhere in this page for a detailed description of these methods. π
π BUGS π
Please send bug reports to the project mailing list: (mged-mage 'at' lists 'dot' sf 'dot' net)
π AUTHOR π
Jason E. Stewart (jasons 'at' cpan 'dot' org)
π«Ά SEE ALSO π«Ά
π POD ERRORS π
Hey! The above document had some coding errors, which are explained below:
- Around line 284:
'=item' outside of any '=over'
- Around line 369:
You forgot a '=back' before '=head2'
- Around line 545:
Expected '=item 2'
- Around line 550:
Expected '=item 3'
- Around line 555:
Expected '=item 4'
and that's the whole vibe check, bestie β this whole page is living in perl v5.32.0 territory and got dated 2020-11-27, so if you're reading it in the future just know she's an elder but she still ate. π β¨ go set some slots, you got this π
π¦ where this page comes from
- debian bookworm: libbio-mage-perl 20030502.3-6 Β· MIT
- debian trixie: libbio-mage-perl 20030502.3-6 Β· MIT
- ubuntu jammy: libbio-mage-perl 20030502.3-6 Β· MIT
- ubuntu noble: libbio-mage-perl 20030502.3-6 Β· MIT
- ubuntu resolute: libbio-mage-perl 20030502.3-6 Β· MIT
- ubuntu stonking: libbio-mage-perl 20030502.3-6 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms