Skip to content

Instantly share code, notes, and snippets.

@emiltin
Created August 7, 2010 23:51
Show Gist options
  • Select an option

  • Save emiltin/513344 to your computer and use it in GitHub Desktop.

Select an option

Save emiltin/513344 to your computer and use it in GitHub Desktop.
class Integer
def divisable? v,b
"#{v%b==0 ? '' : 'not '}dividable by #{b}"
end
def show_divisors *a
info = a.map { |n| "is #{divisable? self,n}" }.join ' and '
puts "The value #{self} #{info}."
end
end
1.upto(10) { |x| x.show_divisors 3,5 }
1.upto(10) { |x| x.show_divisors 3,5,7,9 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment