Test SyntaxHighlighter

February 15, 2008 – 10:00 am

Testing SyntaxHighlighter… 

module EvenOdd
  def even? # is the number even?
    0==self%2
  end

  def odd? # or is it odd?
    0!=self%2
  end
end

Integer.send(:include, EvenOdd)
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • Digg
  • Pownce
  • Reddit
  • Facebook
  • Google
  • Technorati
  • Mixx
  • Slashdot
  • TwitThis
  • Sphinn
  • e-mail
  1. One Response to “Test SyntaxHighlighter”

  2. Clearly the DRY way would be:

    class Integer
      EVEN_ODD_CONFIG = { :even? => '==', :odd? => '>' }
      def method_missing(name)
        if EVEN_ODD_CONFIG.keys.include?(name)
          ( self % 2 ).send(EVEN_ODD_CONFIG[name], 0 )
        else
          super
        end
      end
    end
    

    By Steven Moazami on Feb 15, 2008

Post a Comment