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 Task | |
attr_reader :id | |
attr_accessor :title, :description, :done | |
def initialize(attr = {}) | |
@id = attr[:id] | |
@title = attr[:title] | |
@done = attr[:done] || false | |
@description = attr[:description] | |
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
# CREATING INSTANCES OF REPOSITORIES | |
# make room repo | |
# make doctor repo | |
# pass the room repo to patient repo | |
# make appointment repo | |
# make controllers | |
# make router (which takes all the controllers as arguments) |
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
require_relative "../french_ssn" | |
describe "#french_ssn_info" do | |
it "returns 'The number is invalid' when passed an empty string" do | |
actual = french_ssn_info("") | |
expected = "The number is invalid" | |
expect(actual).to eq(expected) | |
end | |
it "returns 'a man, born in December, 1984 in Seine-Maritime.' when passed '1 84 12 76 451 089 46'" do | |
actual = french_ssn_info("1 84 12 76 451 089 46") |
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 Ingredient | |
has_many :doses | |
belongs_to :alcohol | |
end | |
class Dose | |
belongs_to :ingredient | |
belongs_to :cocktail | |
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 Animal | |
SPECIES = ["lion", "elephant"] | |
attr_reader :name | |
def initialize(name) | |
@name = name | |
end | |
def self.phyla |
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
require_relative "restaurant" | |
class FastfoodRestaurant < Restaurant | |
attr_reader :prep_time | |
def initialize(name, city, capacity, category, prep_time) | |
super(name, city, capacity, category) | |
@prep_time = prep_time | |
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
'01': Ain | |
'02': Aisne | |
'03': Allier | |
'04': Alpes-de-Haute-Provence | |
'05': Hautes-Alpes | |
'06': Alpes-Maritimes | |
'07': Ardèche | |
'08': Ardennes | |
'09': Ariège | |
'10': Aube |
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
# Phone regex with if/else | |
phone_number = "+44 76 4775 4789" | |
if phone_number.match?(/^\+\d{2}\s\d{2}\s\d{4}\s\d{4}$/) | |
puts "This is a valid UK international phone number" | |
else | |
puts "It's not valid!" | |
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
require_relative "../citizen" | |
describe Citizen do | |
# can vote? with a true and falsey condition | |
describe "#can_vote?" do | |
it "should return true for a ctitizen aged 20" do | |
citizen_20 = Citizen.new("bob", "hope", 20) | |
expect(citizen_20.can_vote?).to eq(true) | |
end | |
it "should return false for a citizen of 15" do |
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 BareCitizen | |
# def initialize(name) | |
# @name = name | |
# end | |
def declare | |
puts "I AM #{@name}" | |
end | |
def name(name) |
NewerOlder