Skip to content

Instantly share code, notes, and snippets.

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
# 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
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)
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']
class Card
def initialize(rank = nil, suit = nil)
if suit.nil?
@suit = ['♠', '♣', '♥', '♦'].sample
else
@suit = suit
end
@rank = rank
class Television
def initialize(brand, price, size)
@brand = brand
@price = price
@size = size
end
def brand
def owner
@owner
end
def cylinders
@cylinders
end
def rank
@rank
end
def suit
@suit
end
def owner = (new_owner)
@owner = new_owner
end
def cylinders = (new_cylinders)
@cylinders = new_cylinders
end
class Whiteboard
attr_accessor :contents
def initialize(contents = [])
@contents = contents
end
def erase
@contents= []