to_html

by F.Febles
ilo.rubyforge.org

DESCRIPTION:

Converts an object to an Html structured list.

It’s used basically with Arrays, Hashes, and Enumerable objects.

FEATURES:

You can convert a ‘complex’ object like this one:

h={ :array => [1,2,3,4], :string => ‘test’, :fixnum => 42}

to an Html structured list, that you can beautify using CSS (look for the example)

The easy way to use it is including enumerable in object class:

class Object include ToHtml end Or perhaps better, including only the class or object you are going to use:

class Hash include ToHtml end

Then, you can call to_html in your program:

require ‘to_html’ h={ :array => [1,2,3,4], :string => ‘test’, :fixnum => 42} class Hash include ToHtml end puts ToHtml::TO_HTML_HEAD + h.to_html + ToHtml::TO_HTML_END

You can see a better example in the test folder of the gem, using CSS.

PROBLEMS:

Probably truncates the output of an object that you can’t traverse its structure using ‘each0.

REQUIREMENTS:

We only need parse_tree for tests.

INSTALL:

sudo gem install to_html

LICENSE:

(The MIT License)

Copyright © 2008 FIXME (different license?)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.