Read more

How Ruby lets you keep script and data in *one* file

Dominik Schöler
October 11, 2012Software engineer at makandra GmbH

The __END__ keyword tells Ruby where a file ends – but you don't have to stop there. Any text you add after it is accessible via the DATA object.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

The attached example file data.rb looks like this:

puts DATA.read

__END__
DATA is a File object to everything in the current file after "__END__"

Running it with ruby data.rb prints:

DATA is a File object to everything in the current file after "__END__"
Posted by Dominik Schöler to makandra dev (2012-10-11 20:33)