Fix 'base' stuff
[catagits/XML-Feed.git] / lib / XML / Feed / Entry.pm
index d64a30d..957b488 100644 (file)
@@ -1,9 +1,11 @@
-# $Id: Entry.pm 1865 2005-08-09 20:15:31Z btrott $
+# $Id: Entry.pm 1872 2005-08-12 04:28:42Z btrott $
 
 package XML::Feed::Entry;
 use strict;
 use base qw( Class::ErrorHandler );
 
+use Scalar::Util qw( blessed );
+
 use Carp;
 
 sub wrap {
@@ -18,10 +20,10 @@ sub new {
     my $class = shift;
     my($format) = @_;
     $format ||= 'Atom';
-    my $format_class = 'XML::Feed::' . $format;
+    my $format_class = 'XML::Feed::Format::' . $format;
     eval "use $format_class";
     Carp::croak("Unsupported format $format: $@") if $@;
-    my $entry = bless {}, join('::', __PACKAGE__, $format);
+    my $entry = bless {}, join('::', __PACKAGE__, "Format", $format);
     $entry->init_empty or return $class->error($entry->errstr);
     $entry;
 }
@@ -32,8 +34,11 @@ sub convert {
     my $entry = shift;
     my($format) = @_;
     my $new = __PACKAGE__->new($format);
-    for my $field (qw( title link content summary category author id issued modified )) {
-        $new->$field($entry->$field());
+    for my $field (qw( title link content summary category author id issued modified lat long )) {
+        my $val = $entry->$field();
+        next unless defined $val;
+        next if blessed $val && $val->isa('XML::Feed::Content') && ! defined $val->body;
+        $new->$field($val);
     }
     $new;
 }
@@ -47,6 +52,8 @@ sub author;
 sub id;
 sub issued;
 sub modified;
+sub lat;
+sub long;
 
 1;
 __END__
@@ -83,6 +90,10 @@ returns the new object.
 
 The title of the entry.
 
+=head2 $entry->base([ $base ])
+
+The url base of the entry.
+
 =head2 $entry->link([ $uri ])
 
 The permalink of the entry, in most cases, except in cases where it points
@@ -136,6 +147,14 @@ A I<DateTime> object representing the last-modified date of the entry.
 
 If present, I<$modified> should be a I<DateTime> object.
 
+=head2 $entry->wrap
+
+Take an entry in its native format and turn it into an I<XML::Feed::Entry> object.
+
+=head2 $entry->unwrap
+
+Take an I<XML::Feed::Entry> object and turn it into its native format.
+
 =head1 AUTHOR & COPYRIGHT
 
 Please see the I<XML::Feed> manpage for author, copyright, and license