Created
June 20, 2011 07:40
-
-
Save ipoval/1035266 to your computer and use it in GitHub Desktop.
ruby_ipoval
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://hyperpolyglot.org/scripting | |
$? # global Process::Status object; system('date'); $?.exitstatus; | |
$ ruby -cw filename.rb # checks the code in the file for syntax errors | |
$ ruby -e '1/0' # one-liner ruby executable | |
`gem environment gemdir` | |
# Symbol#to_proc | |
class Symbol | |
def to_proc | |
Proc.new { |obj| obj.send(self) } | |
end | |
end | |
## | |
# Safer RUBY | |
## | |
## | |
# def open_file(file) | |
# ruby_18 {File.open('foo.txt', 'r')} || | |
# ruby_19 {File.open('foo.txt', 'r:UTF-8')} | |
# end | |
# | |
if RUBY_VERSION < '1.9' | |
def ruby_18 | |
yield | |
end | |
def ruby_19 | |
false | |
end | |
else | |
def ruby_18 | |
false | |
end | |
def ruby_19 | |
yield | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment