As @Jim says, you need to access the layer by its ' .name'
So you need something like:
Sketchup.active_model.selection.each{|e|e.material="red" if e.layer**.name**=="Bozworth"}
💡 LightUp 7.1 | SketchUp's only real-time renderer that uses object-based rendering
Download Trial
M