When it is alleged or appears to the Court upon its own view that a person has been guilty of contempt committed in its presence or hearing, the Court may cause such person to be detained in custody, and at any time before the rising of the Court, on the same day or as early as possible thereafter, shall--
(a) cause him to be informed in writing of the contempt with which he is charged, and if such person pleads guilty to the charge, his plea shall be recorded and the Court may in its discretion, convict him thereon;
(b) if such person refuses to plead, or does not plead, or claims to be tried or the Court does not convict him, on his plea or guilt, afford him an opportunity to make his defence to the charge, in support of which he may file an affidavit on the date fixed for his appearance or on such other date as may be fixed by the court in that behalf;
(c) after taking such evidence as may be necessary or as may be offered by such person and after hearing him, proceed either forthwith or after the adjournment, to determine the matter of the charge; and
(d) make such order for punishment or discharge of such person as may be JUst.