The Russian ruble has rallied in the last few weeks thanks to mandatory conversion of foreign currency by Russian export focused companies. Also, there has been weak demand for dollars and euros amid waning imports and restrictions on cross border transactions. The ruble is now more than 30% stronger against the dollar than it was before Russia sent troops into Ukraine on February 24, an event that triggered harsh sanctions from the United States and its allies.
For example, if a Russian company earns $100 from selling a commodity to a company based out of the United States, they have to swap $80 into rubles, regardless of the exchange rate at that specific moment. And because Russia has resilient trade relations with many foreign companies, that move creates significant demand for the Russian ruble, thus also helping to increase it's value.
Payments for Russian gas continue regardless of sanctions. The major gas importing countries Germany and Italy told companies they could open ruble accounts to continue to buy Russian gas without breaching sanctions against Moscow. That statement was made after discussions with the European Union. Other countries like Poland, Bulgaria and Finland have refused to comply with Russia's demand that importers pay for gas via ruble accounts with Gazprombank and their supplies have been entirely cut.
The EU however, said in a written guidance that companies can buy Russian gas without breaching sanctions if they pay in the currency of their existing contracts, and declared that doing so fulfills their contractual obligations.
The Vedomosti daily stated on Monday, that the central bank had started purchasing foreign currency in order to stop the rouble's uncontrolled strengthening. The central bank denied these reports, stating that "this information does not correspond to reality". While the central bank and government leave their restrictions in place, the ruble could continue to strengthen further in the medium term, said Tinkoff Investments analysts.
Sources:
https://qz.com/2167447/how-russia-defended-the-ruble-from-ukraine-war-sanctions/
https://www.bloomberg.com/news/articles/2022-05-23/russia-may-ease-key-fx-limit-as-ruble-surge-hits-budget-economy
https://www.reuters.com/markets/europe/rouble-firms-heading-back-towards-multi-year-highs-vs-dollar-euro-2022-05-23/
https://www.euractiv.com/section/energy/news/germany-and-italy-approved-russian-gas-payments-after-nod-from-brussels/
https://www.euractiv.com/section/energy/news/eu-clarifies-how-companies-can-legally-pay-for-russian-gas-eni-and-rwe-open-bank-accounts/