The method below exists in the Redcloth gem.
My question is: what does the construction "to(RedCloth::Formatters::HTML)" mean? "to" isn’t a method in the class, nor in the superclass (which is String class).
def to_html( *rules )
apply_rules(rules)
to(RedCloth::Formatters::HTML)
end
When you search the entire RedCloth source for
def to, besides finding a couple of methods that start withto, you’ll also find the exact methodtoinext/redcloth_scan/redcloth_scan.rb.rl.There’s two things that happen here. First, this file is preprocessed by Ragel. But for this question, you may safely ignore this fact and read past the weird syntax in that file. Focus on the Ruby bits.
Second, the class
RedCloth::TextileDocis reopend here. That means the class in this file and inlib/redcloth/textile_doc.rbare the same. So thetoinstance method will be available to the piece of code you quoted.