Primarily, do research to learn about ruby. It helped me that I'd learned BASIC back in the day. [When I learned, there was no DOS because there was no Disk - our first computer loaded software from cassette tapes, and the OS was hard-wired. I still remember going with my dad to have the RAM upgraded from 16K to 64K (no joke!), and then coming home from school another time to find two large gray boxes next to the monitor. They happened to be floppy drives (the big 5.25" kind). So much faster than tapes! Then there was that MOdulator-DEModulator to allow computers to connect over phone lines (a "MODEM", it was called). And there was no such thing as a mouse...]
Anyway, I digress. Having any background is helpful, but ruby is easy enough to learn even without a programming background. See http://www.ruby-doc.org/docs/ProgrammingRuby/ for a good introduction and research resource for ruby programming.
Then study the ruby help files for how SketchUp adds its own objects and methods to ruby.
Then study other scripts to see how they are constructed, what methods they use, etc.
Some starting points:
In ruby, the application is referred to as "Sketchup", the model is "Sketchup.active_model", and the geometry is "Sketchup.active_model.entities" (base-level geometry) or "Sketchup.active_model.active_entities" (base- or nested-level geometry).
Any of these things can be assigned to variables:
model=Sketchup.active_model
entities=model.active_entities (because 'model' has been assigned to "Sketchup.active_model", then this assignment is the same as saying "entities=Sketchup.active_model.active_entities")
selection=model.selection
So, there's lesson one. Have fun learning!