Chemistry::Obj(3pm) | User Contributed Perl Documentation | Chemistry::Obj(3pm) |
Chemistry::Obj - Abstract chemistry object
package MyObj; use base "Chemistry::Obj"; Chemistry::Obj::accessor('color', 'flavor'); package main; my $obj = MyObj->new(name => 'bob', color => 'red'); $obj->attr(size => 42); $obj->color('blue'); my $color = $obj->color; my $size = $obj->attr('size');
This module implements some generic methods that are used by Chemistry::Mol, Chemistry::Atom, Chemistry::Bond, Chemistry::File, etc.
There are some common attributes that may be found in molecules, bonds, and atoms, such as id, name, and type. They are all accessed through the methods of the same name. For example, to get the id, call "$obj->id"; to set the id, call "$obj->id('new_id')".
$color = $obj->attr('color'); $obj->attr(color => 'red'); $obj->attr(color => 'red', flavor => 'cherry'); $obj->attr({color => 'red', flavor => 'cherry'});
$bob = Chemistry::Obj->new(name => 'bob', attr => {size => 42});
is equivalent to
$bob = Chemistry::Obj->new; $bob->name('bob'); $bob->attr({size => 42});
Chemistry::Obj overloads a couple of operators for convenience.
<https://github.com/perlmol/Chemistry-Mol>
Chemistry::Atom, Chemistry::Bond, Chemistry::Mol
Ivan Tubert-Brohman <itub@cpan.org>
Copyright (c) 2005 Ivan Tubert-Brohman. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2022-07-14 | perl v5.34.0 |