Skip to content

Instantly share code, notes, and snippets.

@damianesteban
Created November 12, 2013 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damianesteban/7424902 to your computer and use it in GitHub Desktop.
Save damianesteban/7424902 to your computer and use it in GitHub Desktop.
Adaptation of 'Try Ruby'
class BlogEntry
def initialize( title, mood, fulltext )
@time = Time.now
@title, @mood, @fulltext = title, mood, fulltext
end
end
entry_one = BlogEntry.new("Yay Ruby!", :happy, "Ruby is the bomb.")
entry_two = BlogEntry.new("Yay Rails!", :confused, "Rails is the bomb.")
blog = [entry_one, entry_two]
blog.sort_by { |entry| entry.time }.reverse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment