source: flacrip/trunk/lib/DiscFlacFile.pm @ 32

Last change on this file since 32 was 32, checked in by peter, 9 years ago
  • added the DiscFlacFile class
File size: 740 bytes
Line 
1package DiscFlacFile;
2
3use Moose;
4
5use Audio::FLAC::Header;
6use Tracks;
7
8has file => (
9    is  => 'ro',
10    isa => 'Str',
11);
12has flac => (
13    is       => 'ro',
14    isa      => 'Audio::FLAC::Header',
15    builder  => '_load_flac',
16    lazy     => 1,
17    init_arg => undef,
18);
19has tracks => (
20    is       => 'ro',
21    isa      => 'Tracks',
22    builder  => '_load_tracks',
23    lazy     => 1,
24    init_arg => undef,
25);
26
27sub _load_flac { Audio::FLAC::Header->new($_[0]->file) }
28
29sub _load_tracks {
30    my $self = shift;
31    my $tracks = Tracks->new;
32    $tracks->read_flac($self->flac);
33    return $tracks;
34}
35
36sub discid {
37    my $self = shift;
38    return $self->flac->info('MUSICBRAINZ_DISCID') || $self->tracks->discid;
39}
40
41# module return
421;
Note: See TracBrowser for help on using the repository browser.