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
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9] | |
puts "Double every value in array." | |
def double(numbers) | |
numbers.each do |num| | |
puts num *=2 | |
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
# RUBY FUNDAMENTALS III: NON-CORE RETURN VALUE DRILLS | |
# ---------------------------- | |
def is_a_number?(some_string) | |
if some_string =~ /\A\d*[.]{0,1}\d*\z/ | |
true | |
else | |
false | |
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
require 'csv' | |
require 'pry' | |
file = 'lackp_starting_rosters.csv' | |
# Create an empty teams hash | |
teams = {} | |
# Open up the CSV and save it to the variable csv | |
csv = CSV.open(file, headers: true) |
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 'json' | |
require 'pry' | |
data = JSON.parse(IO.read('movies_data.json')) | |
# cast_members = data['movies'][0]['abridged_cast'] | |
# cast_member_names = cast_members.map{|member| member['name']} | |
all_cast_members = [] | |
all_cast_characters = [] | |
movies = data['movies'] |
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
class Card | |
def initialize(rank = nil, suit = nil) | |
if suit.nil? | |
@suit = ['♠', '♣', '♥', '♦'].sample | |
else | |
@suit = suit | |
end | |
@rank = rank |
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
class Television | |
def initialize(brand, price, size) | |
@brand = brand | |
@price = price | |
@size = size | |
end | |
def brand |
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 owner | |
@owner | |
end | |
def cylinders | |
@cylinders | |
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 rank | |
@rank | |
end | |
def suit | |
@suit | |
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 owner = (new_owner) | |
@owner = new_owner | |
end | |
def cylinders = (new_cylinders) | |
@cylinders = new_cylinders | |
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
class Whiteboard | |
attr_accessor :contents | |
def initialize(contents = []) | |
@contents = contents | |
end | |
def erase | |
@contents= [] |