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
require_relative "scraper.rb" | |
puts "Fetching urls..." | |
urls = movie_getter | |
movies = urls.map do |url| | |
puts "Scraping #{url}" | |
scrape_movie(url) | |
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
# CRUD | |
musicians = [ | |
'Arjen Lucassen', | |
'James LaBrie', | |
'Steven Wilson', | |
'Jeff Wayne' | |
] | |
# Create | |
musicians << 'John Lennon' |
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
def acronymize(sentence) | |
sentence.split.map { |word| word[0].upcase }.join | |
end | |
p acronymize('frequently asked questions') |
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
def encrypter(sentence) | |
# Create an array of the alphabet | |
alphabet = ("A".."Z").to_a | |
# Break all the sentences | |
sentence_letters = sentence.split("") | |
# Set our encription key | |
key = -3 | |
# Use map to create one sentence | |
sentence_letters.map do |letter| | |
letter_index = alphabet.index(letter) |
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 './word_counter.rb' | |
# Opens the content from the txt file and reads it into a string | |
text_string = File.open('text.txt').read | |
# Iterates over the hash to print each word on a new line | |
word_counter(text_string).each do |word, count| | |
puts "#{count} -> #{word}" | |
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
def calculate(first_number, operator, second_number) | |
case operator | |
when '+' then first_number + second_number | |
when '-' then first_number - second_number | |
when '*' then first_number * second_number | |
when '/' then first_number / second_number.to_f | |
else "Invalid operator" | |
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
puts "--------------------------" | |
puts "Welcome to the horse race!" | |
puts "--------------------------" | |
horses = ['Caio Andrade', 'Eduardo', 'Marina', 'Lucas', 'Sveta'] | |
loop_input = 'y' | |
while loop_input == 'y' do | |
puts "Here are our horses:" | |
horses.each_with_index do |horse, index| |
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
puts '--------------------' | |
puts 'Welcome to Instacart' | |
puts '--------------------' | |
store_items = { | |
kiwi: 1.25, | |
banana: 0.5, | |
mango: 4.0, | |
asparagus: 9.0 | |
} |
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
# Items and prices | |
store_items = { | |
kiwi: 1.25, | |
banana: 0.5, | |
mango: 4.0, | |
asparagus: 9.0 | |
} | |
# Create a shopping cart for the user | |
shopping_cart = Hash.new(0) |
OlderNewer