How can I do if I want to solve this problems?(ruby script)

Please post code correctly, not images of code …

FYI, in the SketchUp world, width is x-wise. depth is y-wise.

width = group.bounds.width
depth = group.bounds.depth

… or if the bounding box of the group is larger because it contains other elements …

# If you still have a reference to the face, ...
# and if the face is aligned with the model axis:
width = face.bounds.width
depth = face.bounds.depth

Otherwise …

face = group.entities.grep(Sketchup::Face).find {|face| face.normal == Z_AXIS }
if face # always test to be sure something was found !
  # Find an edge whose line vector is parallel to the X axis:
  xface = face.edges.find {|edge| edge.line[1].parallel?(X_AXIS) }
  width = xface ? xface.length : 0
  # Find an edge whose line vector is parallel to the Y axis:
  yface = face.edges.find {|edge| edge.line[1].parallel?(Y_AXIS) }
  depth = yface ? yface.length : 0
  # Test for zero lengths as a failure condition !

But again this assumes that the face and it’s group have not been rotated away from the model axis.

If the group has been rotated, then you cannot test against the model’s axis.
So, you may need to test using group.transformation.xaxis() and group.transformation.yaxis() methods.