Embedding Interactive Ruby Snippets Into Web Pages
Let's say you're a web developer and occasionally need to blog about code. You want to show off how to do this or that. Conventionally, there is no way to do this because browsers only understand HTML, CSS, and Javascript.
With this new javascript plugin called klipsify, I can now run interactive Ruby snippets in the browser. Let's take a tour... (*Note: As of now this only works on non-mobile devices.*)
[9,8] * 2
In the section above, change the “2” to a “20”, so that it says “[9,8] * 20” Did you see the output change? Cool, right?
Let’s show off something more complicated. Let’s write a custom Ruby method called “trumpify”.
def trumpify(text)
"Wow! #{text} Sad!!"
end
trumpify("My campaign is a garbage fire!")
Change "My campaign is a garbage fire" to anything else and the custom ruby method will trumpify it.
In this next example, let’s explore Ruby’s Upcase method.
"Ban Assault Rifles".upcase
Here, we explore the Swapcase method.
"Trump Is A Con Artist.".swapcase
Note that, where words were capitalized, they are now lowercase, and vice versa.
You can check out Klipse here: https://github.com/viebel/klipse
Ok. Thanks for reading.
