Answer
If the paper and ruler touch, the charge transfers from the ruler to the paper and gives them like (and therefore repulsive) charges.
Work Step by Step
See the diagram.
The plastic ruler is electrically charged. When you place it near small bits of paper, it polarizes the molecules of the paper. Within the paper molecules, the charges that are the same sign as the ruler are repelled and shift farther away. The ruler is then attracted to the opposite charges within the paper that are closer to it. The attraction between the unlike charges dominates the repulsion between the like charges, because the unlike charges are closer.
However, if the ruler actually contacts the piece of paper, charge transfer gives the paper a net charge that is the same as the ruler’s. The two like-charged objects then repel.