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
# USER STORIES | |
# - see a list of horses | |
# - place a bet | |
# - see the winning horse | |
# pseudo-code | |
# - initialize user waller with 100€ |
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 List of items (STORE) | |
# => Hash key: name of item, value: price of item (integer) | |
# Welcome user | |
# Show user list of of items | |
# LOOP (more choices) | |
#--- LOOP | |
# Ask user to pick item | |
# Get user choice | |
# validate that choice exists | |
#--- END LOOP |
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
# SETUP: | |
# touch french_ssn.rb | |
# mkdir spec | |
# touch spec/french_ssn_spec.rb | |
# mkdir data | |
# touch data/french_departments.yml | |
# curl -L https://gist.githubusercontent.com/Eschults/279682088e2f87564161e4dbf8390d68/raw/bdbc97ed036a5b21978defd9987e800c7fa67dce > 'data/french_departments.yml' | |
require 'date' | |
require 'yaml' |
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
# USER STORIES | |
# - List the items | |
# - Add an item | |
# - Import item (from Etsy) | |
# - Mark an item as bought/done | |
# - Unmark an item | |
# - Delete an item | |
# show menu | |
# - Initialize a list of items |
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
# SETUP | |
# touch scraper.rb | |
# touch interface.rb | |
# mkdir spec | |
# touch spec/scraper_spec.rb | |
# stt | |
require "yaml" | |
require_relative "scraper" |
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 'nokogiri' | |
require 'pry-byebug' | |
BASE_URL = "https://www.imdb.com" | |
def fetch_urls | |
url = "https://www.imdb.com/chart/top" | |
html_file = open(url).read # string | |
html_doc = Nokogiri::HTML(html_file) #Nokogiri::HTML::Document |
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 Patient | |
attr_reader :name, :cured | |
attr_accessor :id, :room # attr_red + attr_writer | |
# STATE: | |
# - name (String) | |
# - cured (Boolean) | |
# STRATEGY 1 | |
# def initialize(name, cured) |
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
# "Hello" # string | |
# true # boolean | |
# false # boolean | |
# 3 # integer | |
# 3.14 # float | |
# ["Hello", 3, 3.14, true] # array | |
# (1..10) # range | |
# # String interpolation |
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 'date' | |
def days_until_xmas(date = Date.today) | |
# TODO: calculate the number of days | |
# until Christmas | |
current_year = Time.now.year | |
if (Date.new(current_year, 12, 25) - date).to_i < 0 | |
(Date.new(current_year + 1, 12, 25) - date).to_i | |
else | |
(Date.new(current_year, 12, 25) - date).to_i |
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 "How old are you?" | |
age = gets.chomp.to_i | |
# Conditional Statements | |
# if / else structure | |
if age >= 18 | |
puts "You can vote!" | |
else |