Skip to content

Instantly share code, notes, and snippets.

View ashleygwilliams's full-sized avatar

ashley williams ashleygwilliams

  • 14:43 (UTC -05:00)
View GitHub Profile
class Woodchuck
attr_accessor :chuck_count
@@woodchuck_count = 0
WOODCHUCKS = []
def initialize
@chuck_count = 0
@@woodchuck_count += 1
WOODCHUCKS << self

#POKEMON CHALLENGE 1: Data Persistence, pt1

Scraping Bulbapedia everytime we want to make pokemon is probably not a good idea. It's a better idea to scrape just once, and store that data somewhere.

A way we can store that data is a type of data format called YAML. YAML stands for YAML ain't markup language, which isn't super important to know or understand right now.

What's important to know is that we can store our data in a way that looks a little bit like a nested, bulleted, list.

A good example of what this might look like is our student site: https://github.com/ashleygwilliams/webdev_fellowhome/blob/master/data/students.yml

Student Ruby Assessment

Instructions

  • Create a file with "<yourName>_assessment.rb".

Sections 1-6

  • Title each section with a comment that includes the name and number of each section.
  • Then write the ruby that fulfills each lettered instruction under the title. There is no need to structure your code based on the lettered instructions.
  • If you need to use code from a previous numbered section please cut and paste into the approrpriate section.

COMMAND LINE CLASSMATES

##OVERVIEW We are going to create a command line application that allows you to look up the blog and twitter of your fellow classmates.

To start this project, we are going to scrape data from our student website: http://flatironschool-bk.herokuapp.com/

#DELIVERABLE Your project should look like this:

# Hashketball Nests
#
# Great news! You're going to an NBA game! The only catch is that you've been
# volunteered to analyze stats at the game.
# The stats you are given look like this:
game = {
teams: [{
name: 'Lakers',
# Create a test for a method`make_list` that takes an array and returns that same array but
# as an array of strings in a numbered list.
# Run this test by typing `rspec list_maker_spec.rb` in your terminal.
# Then, create a method on array called `make_list` that iterates over the array it is
# called with and appends a number, a period, and a space to each element.
# e.g make_list(["ich", "ni", "san"]) #=> ["1. ich", "2. ni", "3. san"]
def roll_dice
Array.new(5) { rand(1..6) }
end
def win? roll
roll.uniq.length == 1 ? true : false
end
def age_in_years age
age
end
def age_in_days age
age * 365
end
def age_in_dog_years age
age * 7

#SECONDWEEKSCHEDULE (SUBJECT TO CHANGE)

TOPICS COVERED:

  • beginner rspec and rspec expectations
  • methods, parameters, and return values
  • iterating through collections with enumerable
  • blocks and scope

###Day 1

@ashleygwilliams
ashleygwilliams / blackjack.rb
Created November 15, 2013 20:33
Create a folder called 'games' in your todos repo.
#Blackjack!
##Objective
#Practice contional logic including nested conditionals.
#Use methods to keep our code DRY.
##Instructions
#We are going to build a command line blackjack game. A player gets dealt two cards which have values between 1-11. After they get dealt two cards you should show them the total score of their cards and ask them if they want to hit or stay. A player is allowed to "hit" up to two times. After each hit you should ask if they want to hit or stay and display the total value of their cards. If they don't want to hit, and they are not at 21 they lose. Your program should tell them they lose and exit.
#Note: To take input from the person "playing" the game your program will have to use the Ruby method "gets".