Skip to content

Instantly share code, notes, and snippets.

View vuorejo1's full-sized avatar

Joni Huuhtanen vuorejo1

  • Reaktor Innovations Oy
View GitHub Profile
@vuorejo1
vuorejo1 / gist:5973317
Created July 11, 2013 07:35
Analyzer class
class Analyzer
def initialize(target_object)
@object = target_object
end
end
# Implement a DiceSet Class here:
class DiceSet
def initialize
@noppaluvut = self.roll(5)
end
def roll(montako)
@noppaluvut = []
montako.times do
@vuorejo1
vuorejo1 / gist:5922213
Created July 3, 2013 19:56
Ei oo vielä valmis, ihmettelen miksi .each antaa herjan: undefined method `each' for nil:NilClass.. Oon siis ruby koanseja tekemässä.
# Implement a DiceSet Class here:
class DiceSet
def initialize
@noppaluvut = Array.new(5)
end
def roll(montako)
# if montako.size == 0 || montako.size > 6
# raise error?
# arvo noppaluvut, parametri kertoo montako noppaa?
def triangle(a, b, c)
kolmio = [a, b, c]
if a >= 0 || b >= 0 || c >= 0
raise TriangleError.new('No side can be zero or negative')
end
if ((a >= b + c) || (b >= a + c) || (c >= a + b))
raise TriangleError.new('No side can be equal or greater than sum of the other sides')
end
def triangle(a, b, c)
kolmio = Array.new
kolmio = [a, b, c]
if kolmio.size.uniq == 1 then
return :equilateral
elsif kolmio.uniq.size == 2 then
return :isosceles