~ubuntu-branches/ubuntu/saucy/bioperl/saucy-proposed

« back to all changes in this revision

Viewing changes to Bio/Annotation/SimpleValue.pm

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2009-03-10 07:19:11 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090310071911-fukqzw54pyb1f0bd
Tags: 1.6.0-2
* Removed patch system (not used):
  - removed instuctions in debian/rules;
  - removed quilt from Build-Depends in debian/control.
* Re-enabled tests:
  - uncommented test command in debian/rules;
  - uncommented previously missing build-dependencies in debian/control.
  - Re-enabled tests and uncommented build-dependencies accordingly.
* Removed libmodule-build-perl and libtest-harness-perl from
  Build-Depends-Indep (provided by perl-modules).
* Better cleaning of empty directories using find -type d -empty -delete
  instead of rmdir in debian/rules (LP: #324001).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# $Id: SimpleValue.pm,v 1.18.4.3 2006/10/02 23:10:12 sendu Exp $
 
1
# $Id: SimpleValue.pm 14708 2008-06-10 00:08:17Z heikki $
2
2
#
3
3
# BioPerl module for Bio::Annotation::SimpleValue
4
4
#
19
19
   use Bio::Annotation::SimpleValue;
20
20
   use Bio::Annotation::Collection;
21
21
 
22
 
   my $col = new Bio::Annotation::Collection;
23
 
   my $sv = new Bio::Annotation::SimpleValue(-value => 'someval');
 
22
   my $col = Bio::Annotation::Collection->new();
 
23
   my $sv = Bio::Annotation::SimpleValue->new(-value => 'someval');
24
24
   $col->add_Annotation('tagname', $sv);
25
25
 
26
26
=head1 DESCRIPTION
62
62
 
63
63
package Bio::Annotation::SimpleValue;
64
64
use strict;
65
 
use overload '""' => sub { $_[0]->value};
66
 
use overload 'eq' => sub { "$_[0]" eq "$_[1]" };
67
65
 
68
66
# Object preamble - inherits from Bio::Root::Root
69
67
 
74
72
=head2 new
75
73
 
76
74
 Title   : new
77
 
 Usage   : my $sv = new Bio::Annotation::SimpleValue;
 
75
 Usage   : my $sv = Bio::Annotation::SimpleValue->new();
78
76
 Function: Instantiate a new SimpleValue object
79
77
 Returns : Bio::Annotation::SimpleValue object
80
78
 Args    : -value    => $value to initialize the object data field [optional]
121
119
   return "Value: ".$self->value;
122
120
}
123
121
 
 
122
=head2 display_text
 
123
 
 
124
 Title   : display_text
 
125
 Usage   : my $str = $ann->display_text();
 
126
 Function: returns a string. Unlike as_text(), this method returns a string
 
127
           formatted as would be expected for te specific implementation.
 
128
 
 
129
           One can pass a callback as an argument which allows custom text
 
130
           generation; the callback is passed the current instance and any text
 
131
           returned
 
132
 Example :
 
133
 Returns : a string
 
134
 Args    : [optional] callback
 
135
 
 
136
=cut
 
137
 
 
138
{
 
139
  my $DEFAULT_CB = sub { $_[0]->value};
 
140
 
 
141
  sub display_text {
 
142
    my ($self, $cb) = @_;
 
143
    $cb ||= $DEFAULT_CB;
 
144
    $self->throw("Callback must be a code reference") if ref $cb ne 'CODE';
 
145
    return $cb->($self);
 
146
  }
 
147
 
 
148
}
 
149
 
124
150
=head2 hash_tree
125
151
 
126
152
 Title   : hash_tree