Skip to content

Instantly share code, notes, and snippets.

View klustig88's full-sized avatar

Kevin Lustig klustig88

View GitHub Profile

Instructions:

  1. Download this application skeleton.
  2. Convert the app to use AJAX.
  3. Add any files you changed to your gist and submit your code.
@klustig88
klustig88 / flashcards.rb
Created August 16, 2013 22:11
Flash Card Game Core from Week 2
class Question
attr_reader :question, :answer
def initialize(args)
@question = args[0]
@answer = args[1]
end
def to_s
"#{question} - #{answer}"
# This is how you define your own custom exception classes
class NoOrangesError < StandardError
end
class OrangeTree
attr_reader :height, :age
def initialize (height, age)
@height = height
@age = age
# Solution for Challenge: Design Drill: Public vs. Private Interfaces. Started 2013-08-12T16:17:53+00:00
class BankAccount
attr_reader :customer_name, :type, :acct_number
attr_writer :customer_name
def initialize (customer_name, type, acct_number)
@customer_name = customer_name
@type = type
# Solution for Challenge: Ruby Drill: Exploring Scope. Started 2013-08-12T19:15:43+00:00
local_var = 2
THIS_IS_A_CONSTANT = 600
$global_var = 500
# def get_local_var
# local_var
class Person
def self.example_class_method
puts "We're calling an example class method"
puts "'self' is always defined. What is 'self' here? Let's see."
p self
puts "That was self!"
end
def example_instance_method
puts "We're calling an example *instance* method"
class Company
attr_accessor :company_name
attr_reader :employees
def initialize(name)
@company_name = name
@employees = []
end