# Ruby ## Basics ### Create a Ruby Script Create a file named `hello.rb` puts "Hello!" ### Run a Ruby Script $ ruby hello.rb ### Start the Interactive Ruby Shell $ irb 1.9.3-p194 :001 > ### Define a Method def hello puts "Hello!" end ### Call a Method hello ### Define a Method with Argument def hello(name) puts "Hello, #{name}!" end ### Call a Method with an Argument hello("Brian") ### Define a class class Person end ### Instantiate a class brian = Person.new ### Define a Class Initializer class Person def initialize puts "Initialize!" end end ### Define a Class Initializer with Arguments class Person def initialize(name) puts "Initializing '#{name}'" end end ### Instantiate a class using an initializer brian = Person.new("Brian") ### Define an instance method class Person def hello puts "Hello there!" end end ### Call an instance method brian = Person.new("Brian") brian.hello ### Define an Instance Variable ### Define Instance Variable Accessors ### Using Arrays ### Using Hashes ## Intermediate ### Extend a Class class Employee < Person end ### Re-opening Classes ### Define a Class Method ### Call a Class Method ### Blocks ### Symbols ### Define a Module module Hello end ### Define a Module Method module Hello def hello puts "Hello!" end end ### Call a Module Method Hello::hello ### Include a Module include Hello ### Include a module's methods in a class as instance methods ### Include a module's methods in a class as class methods ### Modules vs. Classes ### Ruby Load Path ### Require a Method or Class ## Ruby Gems ### Install a Gem $ gem install pry ## Ruby Version Manager ### Install RVM ### Install Ruby via RVM ## Bundler ### Install Bundler ### Define a project's Gems ### Install a projcet's Gems ## Testing ### RSpec ## Libraries ### Devise ### Guard ## Resources ### Language, Gems & Tools - [Ruby Programming Language](http://www.ruby-lang.org/en/) - [Ruby Gems](http://rubygems.org/) - [Bundler](http://gembundler.com/) - [Ruby Version Manager](https://rvm.io/) - [Ruby on Rails](http://rubyonrails.org/) - [The Ruby Toolbox](https://www.ruby-toolbox.com/) ### Documentation - [Ruby-Doc.org](http://www.ruby-doc.org/) - [RubyDoc.info](http://www.rubydoc.info/) - [APIdock](http://apidock.com/) - [Ruby on Rails API](http://api.rubyonrails.org/) - [Rails Searchable API Doc](http://railsapi.com/) ### Instructional Sites #### Ruby - [Try Ruby](http://tryruby.org/) - [Learn Ruby the Hard Way](http://ruby.learncodethehardway.org/book/) #### Rails - [Ruby on Rails Guides](http://guides.rubyonrails.org/) - [RailsCasts](http://railscasts.com/) - [Rails for Zombies](http://www.codeschool.com/courses/rails-for-zombies-redux) - [Rails for Zombies 2](http://www.codeschool.com/courses/rails-for-zombies-2) - [Rails Best Practices](http://www.codeschool.com/courses/rails-best-practices) - [Testing with RSpec](http://www.codeschool.com/courses/testing-with-rspec) - [PeepCode](https://peepcode.com/) - [Ruby on Rails Tutorial](http://ruby.railstutorial.org/) ### Books - [Programming Ruby 1.9](http://pragprog.com/book/ruby3/programming-ruby-1-9) - [Agile Web Development with Rails](http://pragprog.com/book/rails4/agile-web-development-with-rails) - [Metaprogramming Ruby](http://pragprog.com/book/ppmetr/metaprogramming-ruby) - [Eloquent Ruby](http://eloquentruby.com/) - [The Well-Grounded Rubyist](http://www.manning.com/black2/)