Skip to content

Instantly share code, notes, and snippets.

View Oceantidote's full-sized avatar

Leonard Percival Oceantidote

View GitHub Profile
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
# 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)
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")
class Ingredient
has_many :doses
belongs_to :alcohol
end
class Dose
belongs_to :ingredient
belongs_to :cocktail
end
class Animal
SPECIES = ["lion", "elephant"]
attr_reader :name
def initialize(name)
@name = name
end
def self.phyla
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
'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
# 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
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
class BareCitizen
# def initialize(name)
# @name = name
# end
def declare
puts "I AM #{@name}"
end
def name(name)