This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hash | |
# Accept a hash of values, changes the value in self | |
# from the key in the param to be indexed at the value of param | |
# and returns the new hash. Does not modify self. | |
# | |
# >> a = {"dog" => "meow", "bird" => "tweet" } | |
# => {"bird"=>"tweet", "dog"=>"meow"} | |
# >> a.rename_keys "dog" => "cat" | |
# => {"cat"=>"meow", "bird"=>"tweet"} | |
# >> a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Date | |
def to_words | |
if self == Date.today | |
"Today" | |
elsif self <= Date.today - 1 | |
if self == Date.today - 1 | |
"Yesterday" | |
elsif ((Date.today - 7)..(Date.today - 1)).include?(self) | |
"Last #{self.strftime("%A")}" | |
elsif ((Date.today - 14)..(Date.today - 8)).include?(self) |