Skip to content

Instantly share code, notes, and snippets.

Forked from firedev/colors.rb
Created April 15, 2016 09:41
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Colors.rb – Functional programming in Ruby example
#!/usr/bin/env ruby
require 'paleta'
to_paleta = ->(color) {, color) rescue nil }
to_div = ->(str) {
"<div style='font-family: sans-serif; width: 5em; height: 3em;
line-height: 3em; display: inline-block; text-align: center;
margin: 0.25em; border-radius: 0.25em; padding: 1em;
background: ##{str}'>
}'colors.html', 'w') do |file|
.map(& to_paleta)
.map(& to_div)
`open colors.html`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment