Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

One New Question and bundle update #30

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
source 'https://rubygems.org'


gem 'eventmachine'
gem 'thin'
gem 'sinatra'
Expand Down
25 changes: 25 additions & 0 deletions lib/extreme_startup/question_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ class GeneralKnowledgeQuestion < Question
class << self
def question_bank
[
["who created 'Il pulcino Pio'", "Lucio Scarpa"],
["who is the Prime Minister of Great Britain", "David Cameron"],
["which city is the Eiffel tower in", "Paris"],
["what currency did Spain use before the Euro", "peseta"],
Expand Down Expand Up @@ -396,6 +397,29 @@ def scrabble_scores
end
end

require 'date'
class BeforeDateQuestion < Question
def initialize(player, date=nil)
if date
@date = Date.strptime(date, '%d-%m-%Y')
else
@date = Date.new(2013,rand(11) + 1,rand(27)+1)
end
end

def points
30
end

def correct_answer
@date.prev_day().strftime('%d-%m-%Y')
end

def as_text
"what is the previous day of #{@date.strftime('%d-%m-%Y')}"
end
end

class QuestionFactory
attr_reader :round

Expand All @@ -407,6 +431,7 @@ def initialize
MultiplicationQuestion,
SquareCubeQuestion,
GeneralKnowledgeQuestion,
BeforeDateQuestion,
PrimesQuestion,
SubtractionQuestion,
FibonacciQuestion,
Expand Down