Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Created February 13, 2014 16:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save practicingruby/8978573 to your computer and use it in GitHub Desktop.
Save practicingruby/8978573 to your computer and use it in GitHub Desktop.
Greeter = Object.new
class << Greeter
def greet(name)
"HELLO, #{normalize(name)}!"
end
private
def normalize(name)
name.strip.upcase
end
end
class Person
def initialize(age)
@age = normalize(age)
end
def greet(name)
Greeter.greet(name)
end
private
def normalize(age)
[age.to_i, 25].min
end
end
person = Person.new(12)
p person.greet("Joe")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment