Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

DATA.save

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

DATA.save

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

DATA.save

Stored shit in your script's data segment.

Install

$ gem install DATA.save

Example

A program that records how many times it's been run:

require 'DATA.save'

run_count = DATA.load.to_i
run_count += 1
DATA.save run_count

puts "Run count: #{run_count}"

__END__
0

When we invoke it, it increments the counter, which it stores in its DATA segment.

# run it 3 times
$ ruby count_runs.rb
Run count: 1

$ ruby count_runs.rb
Run count: 2

$ ruby count_runs.rb
Run count: 3

# now check out the file
$ cat count_runs.rb
require 'DATA.save'

run_count = DATA.load.to_i
run_count += 1
DATA.save run_count

puts "Run count: #{run_count}"

__END__
3

License

Just do what the fuck you want to.

http://www.wtfpl.net/about/

FAQs

Package last updated on 18 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc