Sha256: d28dba9b7e6ac67dcb10fd0ea985a40ab9541354dbb991b2d53d9419c9d970a5
Contents?: true
Size: 433 Bytes
Versions: 1
Compression:
Stored size: 433 Bytes
Contents
class Hash # Cast me to a date id by parsing fields for year, month, day. # # hash = {year: "2000", month: "12", day: "31"} # hash.to_date_id # #=> "2000-12-31" # def to_date_id year = self["year"] || self[:year] month = self["month"] || self[:month] day = self["day"] || self[:day] year && month && day ? sprintf("%4.4d-%2.2d-%2.2d", year.to_i, month.to_i, day.to_i) : nil end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sixarm_ruby_to_id-1.0.6 | lib/sixarm_ruby_to_id/hash.rb |