Skip to content

Instantly share code, notes, and snippets.

View yeehaa123's full-sized avatar

Jan Hein Hoogstad yeehaa123

View GitHub Profile
class Session
attr_accessor :number, :name, :date
def initialize(number, name)
@number = number
@name = name
@date = session_date(number)
end
def session_date(number)
x = Array.new
puts "Enter names:"
y = ''
while y !=#nill
y = gets.chomp
x.push y.capitalize
end
x.delete ('')
w = Array.new
class Session
attr_accessor :number, :name, :date
def initialize(number, name)
@number = number
@name = name
@date = session_date(number)
end
def session_date(number)

Ruby, RVM and Mountain Lion

Key problems

Mountain Lion (10.8) has three main difference compared to Lion (10.7):

  • XCode 4.4 does not install Command Line Tools by default
  • X11 isn't available anymore
  • The installed version of OpenSSL has some bugs

How to work around

require 'pry'
class Session
attr_accessor :number, :name, :date, :themes, :presenters
def initialize(number, date)
@number = number
@name = name
@date = date
@themes = []
  • Follow one of the tutorials (again). This is not optional!
  • Formulate one specific problem that you have programming in ruby. Focus your question around a specific concept (instance Class, Object, Boolean, Array -- don't take self or scope!), or method (each, to_s, etc.) that we have encountered so far.
  • Follow the example from the Rspec book step by step
Feature: assign the presenters to a sessions
In order to assign the prestenters to a session
As an instructor of the course 'Arts, Science, and Technology'
I want to have an algorithm to do this for me
Scenario: with just as many participants as sessions
Given a course
And 3 participants in the course
And 3 course sessions
Given(/^a course$/) do
@course = Course.new
end
Given(/^(\d+) participants in the course$/) do |number|
@course.participants = number.to_i.times.map { |i| Participant.new(name: "Participant #{i}")}
end
Given(/^(\d+) course sessions$/) do |number|
@course.sessions = number.to_i.times.map { |i| Session.new(name: "Session #{i}")}
require 'rspec'
class Game
attr_reader :game_values
def initialize
@game_values = %w{rock paper scissors}
end
def start(guess)
if game_values.include? guess
require 'rspec'
class Game
attr_reader :game_values
def initialize
@game_values = %w{rock paper scissors}
end