Permalink
Browse files

more documentation for MediaWiki::Table

git-svn-id: svn://78.47.249.61/ruby-mediawiki/trunk@46 ba9c31aa-a806-0410-9a81-9f13d15ee83b
  • Loading branch information...
1 parent 3a6a489 commit 69f882226590e09dfee2d6cb842f026a9bacd24b sven committed Jan 21, 2006
Showing with 17 additions and 4 deletions.
  1. +17 −4 lib/mediawiki/table.rb
@@ -1,14 +1,25 @@
module MediaWiki
+ ##
+ # The MediaWiki::Table class is used to parse existing
+ # tables from mediawiki articles and to create tables
+ # from arrays. Currently only the mediawiki pipe syntax is
+ # supported.
class Table
+ ##
+ # Initialize a Table instance
+ # data:: [Array]
+ # header:: [Array]
def initialize( data = [], header = [] )
@data = data
@header = header
end
attr_accessor :style, :header_style, :row_style, :data, :header
+ ##
+ # Creates the mediawiki markup to be put in an article
def text
markup = "{| #{@style}\n"
markup += "|---- #{@header_style}\n" if @header_style unless @header.empty?
@@ -20,10 +31,12 @@ def text
markup += "|}"
markup
end
-
- # takes the wiki markup of a table and returns a 2-dimensional array representing the rows and columns of the table
- #
- # TODO: fill member variables according to parsed tables
+
+ ##
+ # Parses the wiki markup of a table and returns a 2-dimensional
+ # array representing rows and columns of the table. Currently only
+ # the mediawiki pipe syntax is supported.
+ # text:: [String]
def self.parse( text )
table, row = nil, nil
text.each_line do | line |

0 comments on commit 69f8822

Please sign in to comment.