Extend your Ruby with Rails

Posted on March 17, 2006

Isn't it nice when you can extend your programming language to the point where you almost speak a human language instead of some obscure one? Check this out:

1
2
3
4
5
6
7
8

$ ./script/console
  >> 30.minutes.ago
  => Wed Feb 15 16:02:08 EST 2006
  >> (1.hour.ago..30.minutes.ago).to_s
  => "Wed Feb 15 15:32:14 EST 2006..Wed Feb 15 16:02:14 EST 2006"
  >> (1.hour.ago..30.minutes.ago).to_s(:db)
  => "BETWEEN '2006-02-15 15:32:19' AND '2006-02-15 16:02:19'"
Post a comment
Comment





You may use Markdown in your comments, so please give your code snippets a four-space indent.