Skip to content

Instantly share code, notes, and snippets.

@ipoval
Created June 20, 2011 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ipoval/1035266 to your computer and use it in GitHub Desktop.
Save ipoval/1035266 to your computer and use it in GitHub Desktop.
ruby_ipoval
# 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