Project

tiny_css

0.0
No commit activity in last 3 years
No release in over 3 years
This rubygem does not have a description or summary.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme
TinyCss
=======

a ruby module to read and write .css stylesheets


Usage
=====

# In your .css file
H1 { color: blue }
H2 { color: red; font-family: Arial }
.this, .that { color: yellow }

# In your program
require 'tiny_css'

# Create a CSS stylesheet
css = TinyCss.new

# Open a CSS stylesheet
css = css.read('style.css')

# Reading properties
# (key is coverted to string, so you can access same value by symbol)
header_color = css.style['h1']['color']
css.style['h2'].each { |property, value| p "#{ property }: #{ value }" }
this_color = css.style[:this][:color]
that_color = css.style[:that][:color]

# Changing styles and properties
css.style['.newstyle']['color'] = '#FFFFFF'  # Add a style
css.style['h1']['color'] = 'black'           # Change a property
css.style['h2'].delete                       # Delete a style

# Save a CSS stylesheet
css.write 'style.css'         # Sort selectors and properties
css.write 'style.css', false  # Don't sort


Install
=======

git clone git://github.com/milk1000cc/tiny_css.git

or

sudo gem install tiny_css


Caution
=======

TinyCss#style doesn't return Hash object but TinyCss::OrderedHash, and TinyCss::OrderedHash class doesn't inherit Hash object.

I'm Japanese, and I'm not goot at English and Ruby, so please see the source code and edit them.


Author
======

milk1000cc <info@milk1000.cc>