Skip to content

Instantly share code, notes, and snippets.

@safarista
Created September 3, 2012 18:23
Show Gist options
  • Save safarista/3611733 to your computer and use it in GitHub Desktop.
Save safarista/3611733 to your computer and use it in GitHub Desktop.
Trying to replicate God Almighty on the 6th day of the creation theorem
# encoding: utf-8
# and afetr he had created everything and saw it was good
# ..."On the 6th day he made man and rested on the 7th day"
# so lets make some babies
class Person
def initialize(names, age, gender, status, job = 'Jobless for now')
@names = names
@age = age
@gender = gender
@status = status
# @job # No need to define this because its already defined
@@count = 0 # This is used to store the number of people we create/initiallize
end
def yawn
'Yaaaaaaaaawnnnn!'
end
def sport
'athletics!'
end
# ... define some more actions here
private
# Everything private is only accessible within this class i.e. Person
def weight(mass)
# weight = mass(kilograms) * gravity(10 NKg-1). Simply w = m*a
@weight = mass * 10
end
end
# Our first baby can be concieved in this manner
baby1 = Person.new
baby1.names = 'John Doe'
baby1.age = '1 day'
baby1.gender = 'M'
baby1.status = 'Under construction'
# Our 2nd baby was concieved like this
baby2 = Person.new (names: 'Wendy Jane Doe', age: '2', gender: 'F', status: 'Toddler')
baby1.names # => John Doe
baby2.names # => Windy Jane Doe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment