File: EntryType.pm

package info (click to toggle)
liboptimade-propertydefinitions-perl 0.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,996 kB
  • sloc: sh: 348; perl: 184; python: 38; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 824 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package OPTIMADE::PropertyDefinitions::EntryType;

# ABSTRACT: OPTIMADE Entry Type
our $VERSION = '0.1.0'; # VERSION

use strict;
use warnings;

use OPTIMADE::PropertyDefinitions::Property;

sub new
{
    my( $class, $parent, $name ) = @_;
    return bless { parent => $parent, name => $name }, $class;
}

sub property($)
{
    my( $self, $property ) = @_;
    die "no such property '$property'\n" unless $self->raw->{properties}{$property};
    return OPTIMADE::PropertyDefinitions::Property->new( $self, $property );
}

sub properties()
{
    my( $self ) = @_;
    return map { OPTIMADE::PropertyDefinitions::Property->new( $self, $_ ) }
               sort keys %{$self->raw->{properties}};
}

sub name() { $_[0]->{name} }
sub parent() { $_[0]->{parent} }

sub raw() { $_[0]->parent->raw->{entrytypes}{$_[0]->name} }

1;