This file contains 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
# methods.rb | |
# method names should be snake_cased | |
# no arguments | |
def random_method | |
return 10 | |
end | |
# puts random_method |
This file contains 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
"Ricardo" #=> String | |
4 #=> Integer | |
4.6 #=> Float | |
[1,2,3] #=> Array | |
(1..10) #=> Range | |
false #=> FalseClass (Boolean) | |
true #=> TrueClass (Boolean) | |
nil #=> NilClass |
This file contains 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
.counter { | |
padding: 50px; | |
width: 200px; | |
margin: auto; | |
display: flex; | |
align-items: center; | |
} | |
.counter button { | |
font-size: 2em; |
This file contains 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
# You can use a global variable, DB, which | |
# is an instance of SQLite3::Database | |
# NO NEED TO CREATE IT, JUST USE IT. | |
require 'sqlite3' | |
require 'pry-byebug' | |
db_file_path = File.join(File.dirname(__FILE__), "../../spec/support/posts_spec.db") | |
DB = SQLite3::Database.new(db_file_path) | |
DB.results_as_hash = true |
This file contains 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
#root > div { | |
display: flex; | |
height: 100vh; | |
} | |
.left-scene { | |
flex: 0 0 60%; | |
position: sticky; | |
display: flex; | |
flex-direction: column; |
This file contains 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
# controller.rb | |
require_relative 'view' | |
require_relative 'task' | |
class Controller | |
def initialize(repository) | |
@repo = repository | |
@view = View.new | |
end |
This file contains 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
# chef.rb | |
class Chef | |
attr_reader :name, :restaurant | |
def initialize(name, restaurant) | |
@name = name # String instance | |
@restaurant = restaurant # Restaurant instance | |
end | |
end |
This file contains 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 Citizen | |
# attr_reader :first_name, :last_name, :age | |
attr_reader :age, :height | |
def initialize(first_name, last_name) | |
@first_name = first_name | |
@last_name = last_name | |
@age = 0 | |
@height = rand(10..40) | |
@alive = true |
This file contains 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
# car.rb | |
class Car | |
# attr_reader :color, :brand | |
attr_reader :brand | |
# attr_writer :color | |
attr_accessor :color | |
# initializer or constructor | |
def initialize(color, brand) |
This file contains 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
# chef.rb | |
class Chef | |
attr_reader :name, :restaurant | |
def initialize(name, restaurant) | |
@name = name # String instance | |
@restaurant = restaurant # Restaurant instance | |
end | |
end |
NewerOlder