Skip to content

Instantly share code, notes, and snippets.

@xhezairbey
Last active August 29, 2015 14:09
Show Gist options
  • Save xhezairbey/fc1afb768343374d83e5 to your computer and use it in GitHub Desktop.
Save xhezairbey/fc1afb768343374d83e5 to your computer and use it in GitHub Desktop.
The Ruby Beard Test
# Pretty print your Ruby objects with style -- in full color and with proper indentation
# https://github.com/michaeldv/awesome_print
require 'awesome_print'
=begin
* Name: Beard Test App
* Description: Person Beard Scanner
* Author: @xhezairi & @korabh
* Date: Today
* License: MMV
=end
class Person
attr_accessor :name, :beard, :size
# Default measurement unit 'finger'
def initialize(name, beard = false, size = 0)
@name = name
@beard = beard
@size = size
end
def beard_size
return 'Oh, you! Never mind mate.' if @name =~ /isis/i
# It should be >4 unless you want to take.thawab
unless @beard == nil
case @size
when 0..1
return 'You call that a beard?! Dude.'
when 2..3
return 'C\'mon. Let it grow bro! ;-)'
when 4..5
return 'MashAllah. +1 Thawab. You earned it!'
else
return "Homosapiense."
end
else
grow_beard_mofo
end
end
private
def grow_beard_mofo
if beard.nil?
@beard = true
return 'Facial hair on place, Shaveman!'
end
end
end
person1 = Person.new('Xhabir Hamiti', nil, 0)
person2 = Person.new('Hamza Binaj', true, 4)
person3 = Person.new('Annon ISIS Member', true, 6)
people = [person1, person2, person3]
people.each do |person|
puts "------"
puts "#{person.name}: #{person.beard_size}"
end
puts 'Live happily ever-after!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment