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
# Red Green Blue - > RGB | |
# English Premier League - > EPL | |
def acronym(sentence) | |
# TODO: Define a method that returns the acronyms | |
# of a sentence, using a stronger iterator than #each | |
# split setence into words (split) | |
# go through each element | |
# grab the first letter and capitalize it |
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
# Welcome user | |
# Display list of horses / roster [array] | |
# User picks a horse | |
# Randomly select winning horse (sample) / (shuffle) | |
# Determine if user won | |
# Display results | |
# Ask user if they want to play again | |
# 0 1 2 3 | |
HORSES = ["Bronco", "Tweaker", "Michael Bolton", "Jack Sparrow", "John Wayne"] |
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
# Welcome the user | |
# Display the stock/list of products | |
# Get user choice | |
# ask quantity | |
# save quantity | |
# Check if it's available | |
# Add to cart | |
# Ask if they want continue shoppinh | |
# Add total and display bill |
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
# Write a #french_ssn_info method extracting infos from French SSN (Social Security Number) using regexp. | |
# Valid French SSN numbers have the following pattern: | |
# "1 84 12 76 451 089 46" | |
# Gender (1 == man, 2 == woman) | |
# Year of birth (84) | |
# Month of birth (12) | |
# Department of birth (76, basically included between 01 and 99) |
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
# Welcome user | |
# LISTS: collections of records (Array) | |
# RECORDS: objects w/ attributes (name, etc...) | |
# (loop) | |
# Get user which action [list|add|delete|quit] | |
# Check if action exists | |
# LIST |
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 'sqlite3' | |
require 'byebug' | |
# ruby multi-line syntax: | |
# <<-SQL (SQL is a tag name of your choosing) | |
# string line 1 | |
# string line 2 | |
# ... | |
# SQL (closes the tag) |
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 |
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
# #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
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 |
OlderNewer