Skip to content

idealprojectgroup/colorizable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Colorizable

Build Status

This library provides integration of the color gem with Rails. Use 'colorize' to specify which fields you want to be backed by Color::RGB objects.

Install

Add the gem to your application's Gemfile:

gem 'colorizable'

And execute:

bundle

You can also install it yourself using:

gem install colorizable

Usage

ActiveRecord

The Uniform model has three string columns called primary_color, secondary_color, and font_color. Each column has a hex value stored in it. Instead of dealing with a string, it would be helpful to deal with Color::RGB objects which provide a number of helpers.

class Uniform < ActiveRecord::Base

  colorize :primary_color, :secondary_color, :font_color

end

Each color on the model is now a Color::RGB object. The objects come with a number of helpers to convert the color to other formats like rgb.

uniform = Uniform.new
uniform.primary_color = "#cccccc"
uniform.primary_color.red # 204
uniform.primary_color.green # 204

uniform.secondary_color = { r: 204, g: 204, b: 204 }
uniform.secondary_color.to_s # #cccccc

How to contribute

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Write your tests and check everything passes
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request (into the master branch)

License

Please refer to LICENSE.

About

Provides an integration of the color gem with Rails

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages