| ⌘T | go to file |
| ⌘⌃P | go to project |
| ⌘R | go to methods |
| ⌃G | go to line |
| ⌘KB | toggle side bar |
| ⌘⇧P | command prompt |
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
| require 'pg' | |
| class Contact | |
| attr_reader :id | |
| attr_accessor :firstname, :lastname, :email | |
| def initialize(firstname, lastname, email, id = nil) | |
| @firstname = firstname | |
| @lastname = lastname | |
| @email = email |
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
| 123 |
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
| CREATE TABLE person ( | |
| id INTEGER PRIMARY KEY, | |
| first_name TEXT, | |
| last_name TEXT, | |
| age INTEGER | |
| ); | |
| CREATE TABLE pet ( | |
| id INTEGER PRIMARY KEY, | |
| name TEXT, |
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 Game | |
| attr_accessor :game_over | |
| attr_reader :player_turn | |
| def initialize | |
| @game_over = false | |
| @player_turn = 1 | |
| end | |
| def turn_changer | |
| return @player_turn == 1 ? @player_turn = 2 : @player_turn = 1 | |
| 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 Animal | |
| attr_accessor :name, :num_legs, :warm_blood | |
| def initialize(name, num_legs, warm_blood) | |
| @name = name | |
| @num_legs = num_legs | |
| @warm_blood = warm_blood | |
| 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
| require 'open-uri' | |
| require "rubygems" | |
| require "rest-client" | |
| #### EXERCICE 1 | |
| # assign the url source to a var | |
| url = "http://ruby.bastardsbook.com/files/fundamentals/hamlet.txt" | |
| # seting a var with the file name you want to creat | |
| local_fname = "hamlet.txt" | |
| # using File.open in "w"rite mode to write a hamlet.txt file |
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 Game | |
| attr_accessor :game_over, :player_turn | |
| def initialize | |
| @game_over = false | |
| @player_turn = 1 | |
| end | |
| def turn_changer | |
| return @player_turn == 1 ? @player_turn = 2 : @player_turn = 1 | |
| end | |
| # def game_over(game) |
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
| def quote_maker(dimension,colours) | |
| price = dimension * dimension * 15.to_f | |
| if colours <= 2 | |
| colour_cost = 10 * colours | |
| price = price + colour_cost | |
| elsif colours > 2 | |
| colour_cost = 15 * colours | |
| price = price + colour_cost | |
| end | |
NewerOlder