Carbon nanotubes are of great interest for their ability to functionalize with atoms for adsorbing toxic gases such as CO, NO, and NO2. Here, we use density functional theory in conjunction with dispersion correction to examine the encapsulation and adsorption efficacy of SO2 and H2S molecules by a (14,0) carbon nanotube and its substitutionally doped form with Ru. Exoergic encapsulation and adsorption energies are calculated for pristine nanotubes. The interaction of molecules with pristine nanotube is non-covalent as confirmed by the negligible charge transfer. The substitutional doping of Ru does not improve the encapsulation significantly. Nevertheless, there is an important enhancement in the adsorption of molecules by Ru-doped (14,0) nanotube. Such strong adsorption is confirmed by the strong chemical interaction between the nanotube and molecules. The promising feature of Ru-doped nanotubes can be tested experimentally for SO2 and H2S gas sensing.