Inspired by Literate CoffeeScript.
$ cat hello.rb.md
Here's a simple program
puts "Hello, world"
$ ruby litrb.rb < hello.rb.md
Hello, world
| import Control.Monad | |
| import Control.Concurrent | |
| import Control.Concurrent.STM | |
| import System.Random | |
| import Text.Printf | |
| -- Forks | |
| type Fork = TMVar Int | |
| newFork :: Int -> IO Fork |
Inspired by Literate CoffeeScript.
$ cat hello.rb.md
Here's a simple program
puts "Hello, world"
$ ruby litrb.rb < hello.rb.md
Hello, world
| @font-face { | |
| font-family: 'EntypoRegular'; | |
| src: url('font/entypo.eot'); | |
| src: url('font/entypo.eot?#iefix') format('embedded-opentype'), | |
| url('font/entypo.woff') format('woff'), | |
| url('font/entypo.ttf') format('truetype'), | |
| url('font/entypo.svg#EntypoRegular') format('svg'); | |
| font-weight: normal; | |
| font-style: normal; | |
| } |
| # A few examples about how to use Ruby for parsing files as we could do | |
| # with Awk or Grep. This is based on what I learn fro this post: | |
| # http://code.joejag.com/2009/using-ruby-as-an-awk-replacement/ | |
| # Split each line with ':' and print the first $F[0] field | |
| awk -F: '{ print $1 }' /etc/passwd | |
| ruby -F: -nae 'puts $F[0]' /etc/passwd | |
| # Parse the 'ps aux' output | |
| # It'll print the ID process for the 'jojeda' user |