[MKDoc-commit] [1.6] New methods determine which child of the root document is an

bruno at mkdoc.demon.co.uk bruno at mkdoc.demon.co.uk
Wed Jan 5 14:23:04 GMT 2005


Log Message:
-----------
[1.6] New methods determine which child of the root document is an
ancestor and lay out lists of children with percentages.

Tags:
----
mkdoc-1-6

Modified Files:
--------------
    mkd/flo/Record:
        Document.pm

-------------- next part --------------
Index: Document.pm
===================================================================
RCS file: /var/spool/cvs/mkd/flo/Record/Document.pm,v
retrieving revision 1.25.2.68
retrieving revision 1.25.2.69
diff -Lflo/Record/Document.pm -Lflo/Record/Document.pm -u -r1.25.2.68 -r1.25.2.69
--- flo/Record/Document.pm
+++ flo/Record/Document.pm
@@ -1093,6 +1093,21 @@
 
 
 ##
+# $self->root_child();
+# --------------------
+# Returns the ancestor of this document that is a child of the root document.
+##
+sub root_child 
+{
+    my $self = shift;
+    my $ancestors = $self->ancestors;
+    return unless $ancestors;
+    return $self unless $ancestors->[1];
+    return $ancestors->[1];
+}
+
+
+##
 # $self->position();
 # ------------------
 # Gets the sibling position of that document, i.e. where it
@@ -1682,6 +1697,22 @@
 
 
 ##
+# $self->children_showable_percent_each()
+# ---------------------------------------
+# returns 25% if there are 4 children, 12.5% if there are eight etc..
+# css percentages are decimal numbers, not necessarily integers
+# http://www.w3.org/TR/REC-CSS2/syndata.html#value-def-number
+##
+sub children_showable_percent_each
+{
+    my $self = shift;
+    my $children_showable = $self->children_showable;
+    my $number = @$children_showable || return;
+    return (100 / $number) . '%';
+}
+
+
+##
 # $self->cousins_homonyms();
 # --------------------------
 # Returns a list of cousins which are also homonyms.


More information about the MKDoc-commit mailing list