Ruby Monstas


The Ruby Standard Library

The Ruby Distribution

    • Ruby Standard Library
      More advanced Classes/Features
    • Ruby Core
      Strings, Symbols, Array, Hashes, ...
    • Ruby Language
      Syntax

Contents / Purpose

The Ruby Standard Library is an extensive set of advanced tools.
These tools provide functionalities for common problems.
We'll see examples later
The Library is built-in, so we don't have to install anything.

Example - SecureRandom

require 'securerandom'

SecureRandom.alphanumeric(15)       # => FvUMIA00NVLijK0
SecureRandom.random_number(1..1000) # => 795
SecureRandom.hex(10)                # => 664bd09321b3ae235fb3
https://ruby-doc.org/stdlib/libdoc/securerandom/rdoc/SecureRandom.html

Example - Time

require 'time'

firework_start = Time.parse("2020-12-31 23:59:59")
firework_end = Time.parse("2021-01-01 00:09:59")

seconds = firework_end - firework_start # => 600.0

firework_start.strftime("%A") # => Thursday
firework_end.strftime("%A")   # => Friday
https://ruby-doc.org/stdlib/libdoc/time/rdoc/Time.html

More libraries

  • Networking
    Web, E-Mail, Sockets, ...
  • Advanced Math
    Prime number generator, Matrices, Complex numbers, ...
  • Data format libraries
    CSV, JSON, XML, YAML, RSS, ...
  • Many, many more
    Date/Time, Simple Databases, Cryptography, Advanced Data Structures,
    Debugging, Profiling, Introspection, ...

Additional Resources

What questions do you have?