The SketchUp API simply adds modules and classes to Ruby. It really helps to learn Ruby first. (Other topics)
- Learning Ruby and the SketchUp API
- Attempting to learn Ruby
- What’s the best way to start developing?
Such as iterating standard Ruby collection classes (Array, Set, Hash.) Many of the iterator methods are not documented in the SketchUp API docs, they are documented in the Ruby docs:
http://ruby-doc.org/core-2.0.0
Also, regarding your “selection” problem above, …it is likely not safe to push references to objects in different contexts, into the SketchUp selection collection. (… if it is even allowed.)
EDIT: But you can push whatever references you have into your own collections (Array, Hash, whatever.)
There is a thread in which I’ve already posted iterator code to find components and groups by name.
(Moving to the Ruby API category.)