Skip to content


Add 22: "Literate Ruby"
Browse files Browse the repository at this point in the history
  • Loading branch information
janlelis committed May 22, 2015
1 parent df08194 commit 751cdf3
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions source/posts/
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
title: Literate Ruby
date: 2015-05-22
tags: cli-options

Ruby has a built-in feature that is much like [Literate CoffeeScript]( In contrast to it, this Ruby option will not ignore literature, but garbage:


## `-x[directory]`

Tells Ruby that the script is embedded in a message.
Leading garbage will be discarded until the first line
that starts with “#!” and contains the string, “ruby”.
Any meaningful switches on that line will be applied.
The end of the script must be specified with either EOF,
^D (control-D), ^Z (control-Z), or the reserved word
__END__. If the directory name is specified, Ruby will
switch to that directory before executing script.


#! Let's see this in action, using this blog post about ruby
puts "Idiosyncratic Ruby"
Paste the whole content of this article into a file and execute it with:

$ ruby -x FILENAME

## Further Reading

- `man ruby`

0 comments on commit 751cdf3

Please sign in to comment.