Inserting a group or component with Ruby API

(1) A short piece of code (snippet) can be posted correctly in the forum.
(I’m not going to download such a small file and open it in my code editor.)

(2) A group of what ? All the entities you’ve created in the method ?
If so, then do not add them to the model’s entities collection. Instead create a group or a component definition, and then add the geometry to their entities collection.

from an example in the Sketchup::Group class documentation

# Add a group to the model.
group = Sketchup.active_model.entities.add_group
group.entities.add_line([0,0,0],[100,100,100])

You can also make a reference to the group’s entities collection object …

# Add a group to the model:
group = Sketchup.active_model.entities.add_group
# Reference it's entities collection:
ents1 = group.entities
enst1.add_line([0,0,0],[100,100,100])

Be sure to quickly add drawingelements or objects to the group’s entities or the SketchUp engine will delete the groups “out from under you”.

Many coders immediately put a cpoint at the group’s origin to prevent SketchUp from deleting the group. …

# Add a group to the model:
group = Sketchup.active_model.entities.add_group
# Reference it's entities collection:
ents1 = group.entities
# Add a guide point at the group's origin:
cpt = enst1.add_cpoint([0,0,0])

… then later after adding things to the group, they delete the guide point …

cpt.erase!