Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ruby colors program  RSS feed

 
ransome hadoop
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am new to ruby programming(like 4 classes of teaching). I am
writing a ruby script that extracts hexadecimal color codes out of a
Cascading Style Sheet (CSS) file. the script takes 2 command line
arguments. A location of css file and a filename to write out the
report. the script generates a html page that displays color swatches
with their RGB and hexadecimal values. I need help on how to open files
and match colors and output it in html page. i have to match the sample output provided below

My code:









A sample CSS file:


sample output

 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

I've been doing Ruby for about seven months now ... (phrasing!) ... so I'm not exactly an expert either. I've been programing a long, long time though, and some concepts are universal.

Basically, you're asking us to solve a homework problem for you, which we don't do, but we can nudge in the right direction. Your short script shows (on line 7) the correct regex for parsing out color strings, but actually uses a different one for some reason. The way I'd start with this is ignore the output file, and just build up a hash keyed by the colors you parse out, and counting how many times you've seen each one. Get that done, and then we can talk about formatting the output.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!