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
| # 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
| # 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 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
| # 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
| # 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
| def calculate(first_number, second_number, operator) | |
| case operator | |
| when "+" | |
| first_number + second_number | |
| when "-" | |
| first_number - second_number | |
| when "*" | |
| first_number * second_number | |
| when "/" | |
| first_number / second_number |
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
| # #frequencies method | |
| # should return and empty hash when passed an empty string | |
| # should count words | |
| # should count multiple words | |
| # should be case insensitive | |
| # should ignore short words and punctuation (. ! ? ,) | |
| # #read_file method | |
| # should read the dummy 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
| lisbon = { | |
| # key => value | |
| "country" => "Portugal", # string | |
| "population" => 2821876 # integer | |
| } | |
| # puts Lisbon.class | |
| # uninitialized constant Lisbon (NameError) | |
| # the program does not know a variable/constant named Paris | |
| # (because we have not defined one) |
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
| # Set up a /slug/ route to your #index in routes.rb | |
| # get '/search/:slug', to: 'restaurants#index' | |
| class RestaurantsController < ApplicationController | |
| def index | |
| if params[:slug] | |
| lookup = SlugLookupService.new(params[:slug]) | |
| lookup.perform | |
| category = lookup.category | |
| redirect_to restaurants_path unless category |