Commits

Anonymous committed 0d8cdef

Refactoring - cleaned up _movenext.

Comments (0)

Files changed (2)

+
+    - Refactoring: converted _movenext() from pseudo-conditionals
+    to polymorphism by making it a method of ->_current().
+
 0.1.2 - Sun Oct 26 12:57:55 IST 2008
     - Corrected the README.
     - Now checking for inodes that are 0, when checking for cyclical trees,

lib/File/Find/Object.pm

     return $top->_open_dir() ? $self : undef;
 }
 
+sub _move_next
+{
+    my ($self, $top) = @_;
+
+    # TODO :
+    # Implement traversal to files with the filenames of exactly "0".
+    if ($self->_curr_file(
+            shift(@{$top->_father($self)->_traverse_to()})
+       ))
+    {
+        $self->_reset_actions();
+        return 1;
+    } else {
+        return 0;
+    }
+}
+
 package File::Find::Object;
 
 use strict;
     _current
     _father_components
     _me_die
-    _movenext
     )]
 );
 
         {
             return $self->_calc_current_item_obj();
         }
-        if(!$self->_movenext) {
+        if(!$self->_top_move_to_next) {
             if ($self->_me_die())
             {
                 return undef();
     return $self->_father($self->_current);
 }
 
-sub _non_top__movenext
-{
-    my $self = shift;
-    if ($self->_current->_curr_file(
-            shift(@{$self->_current_father->_traverse_to()})
-       ))
-    {
-        $self->_current->_reset_actions();
-        return 1;
-    } else {
-        return 0;
-    }
-}
-
 sub _increment_target_index
 {
     my $self = shift;
     return $self->_curr_file($self->_calc_next_target());
 }
 
-sub _top__movenext
+sub _move_next
 {
     my $self = shift;
 
     return 0;
 }
 
+sub _top_move_to_next {
+    my $self = shift;
+
+    return $self->_current()->_move_next($self);
+}
+
 sub _top__me_die {
     return 1;
 }