a ruby module to read and write .css stylesheets
License
milk1000cc/tiny_css
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
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>
About
a ruby module to read and write .css stylesheets
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published