Welcome to the Ruby repository! 🎉
This repository is a curated collection of Ruby code samples with accompanying notes and comments.
To explore the examples in this repository, ensure you have Ruby installed on your system.
Clone this repository to your local machine:
git clone https://github.com/your-username/ruby.git
cd ruby
Run any Ruby file using the ruby
command:
ruby path/to/file.rb
This repository includes the following:
- blocks/: Examples demonstrating Ruby blocks, including iterators and yielding.
basics.rb
: Introduction to blocks and their usage.each.rb
: Examples of theeach
method and iterators.enumerable.rb
: Usage of theEnumerable
module for collections.yielding.rb
: Advanced examples of yielding to blocks.timing.rb
: Measuring execution time using blocks.sensor.rb
: Simulating sensor checks with blocks.debugging.rb
: Using blocks for debugging output.benchmark.rb
: Measuring code execution time with the Benchmark module.expectation.rb
: Simple expectation-based test helper using blocks.tag.rb
: Generating HTML tags using blocks.phone.rb
: Example demonstrating a simple phone class and usage.initializer.rb
: Demonstrates object initialization with blocks and attribute assignment.resources.rb
: Managing resources (files, network, etc.) safely with blocks.database_driver.rb
: Managing database connections safely with blocks, similar toresources.rb
but for databases.database_driver_extra.rb
: Extends the database driver example to include transaction management using blocks, following the same resource safety concepts.
This project is licensed under the MIT License.