Skip to content

Commit 751cdf3

Browse files
committed
Add 22: "Literate Ruby"
1 parent df08194 commit 751cdf3

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: Literate Ruby
3+
date: 2015-05-22
4+
tags: cli-options
5+
---
6+
7+
Ruby has a built-in feature that is much like [Literate CoffeeScript](http://coffeescript.org/#literate). In contrast to it, this Ruby option will not ignore literature, but garbage:
8+
9+
ARTICLE
10+
11+
## `-x[directory]`
12+
13+
Tells Ruby that the script is embedded in a message.
14+
Leading garbage will be discarded until the first line
15+
that starts with “#!” and contains the string, “ruby”.
16+
Any meaningful switches on that line will be applied.
17+
The end of the script must be specified with either EOF,
18+
^D (control-D), ^Z (control-Z), or the reserved word
19+
__END__. If the directory name is specified, Ruby will
20+
switch to that directory before executing script.
21+
22+
Awesome!
23+
24+
<pre>
25+
#! Let's see this in action, using this blog post about ruby
26+
puts "Idiosyncratic Ruby"
27+
__END__
28+
</pre>
29+
Paste the whole content of this article into a file and execute it with:
30+
31+
$ ruby -x FILENAME
32+
33+
## Further Reading
34+
35+
- `man ruby`

0 commit comments

Comments
 (0)