This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cat | |
attr_reader :color, :breed #:name | |
attr_accessor :name #instead of mentioning the attribute both in reader and writer, we can do both in the same time with accessor | |
#attr_writer :name | |
def initialize(color, breed) | |
@color = color | |
@breed = breed | |
@hungry = true | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Pet | |
attr_reader :color, :breed | |
attr_accessor :name | |
def initialize(color, breed) | |
@color = color | |
@breed = breed | |
@hungry = true | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "please type rock, scissors or paper" | |
player = gets.chomp | |
rand(1..3) | |
if rand(1..3) == 1 | |
computer = "rock" | |
elsif rand(1..3) == 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProductsController < ApplicationController | |
before_action :set_product, only: [:show, :edit, :update, :destroy] | |
# GET /products | |
# GET /products.json | |
if RAILS_ENV == "development" | |
def index | |
if params[:q] | |
search_term = params[:q] | |
@products = Product.where("name LIKE ?", "%#{search_term}%") |
I hereby claim:
- I am kajatiger on github.
- I am kaja (https://keybase.io/kaja) on keybase.
- I have a public key ASAO66UqrqbLKnDk80464wvNiZKKoA9xhrdv9goUn8G-ego
To claim this, I am signing this object:
OlderNewer