When you browse the entire RedCloth source for def to , in addition to searching for a few methods starting with to , you will also find the exact to method in ext/redcloth_scan/redcloth_scan.rb.rl .
There are two things here. Firstly, this file is pre-processed by Ragel . But on this subject, you can safely ignore this fact and read the last strange syntax in this file. Focus on the Ruby bits.
Secondly, the RedCloth::TextileDoc class RedCloth::TextileDoc . This means that the class in this file and in lib/redcloth/textile_doc.rb match. This way, the to instance method will be available for the code snippet you specified.
source share