Advertisement
UnRar

Ruby Class is so Sexy

Aug 13th, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.45 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. #Let's start with a Sexy Class!
  3. class Selector
  4.     #Our "constructor"
  5.     def initialize(lang)
  6.         @lang = lang
  7.     end
  8.     #Our magic function
  9.     def better?
  10.         if @lang.downcase == "ruby"
  11.             puts "You just choosed the best language! Congrats!\n"
  12.         else
  13.             puts "Ruby is better than #{@lang}!\n"
  14.         end
  15.     end
  16. end
  17.  
  18. #Now we create a sexy object
  19. perl = Selector.new("Perl")
  20. #Let's ask the magic class what's the better language
  21. perl.better?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement