Just wondering what the best way to represent an activity with a few fragments in UML or more specifically a Class Diagram.
That depends on the point of view.
The most thorough analysis of fragments can be done by Object diagram or Composite Structure Diagram.
If you want to model their outer behaviour, Component diagram or any of behavioral diagrams will do.