Module ApplicationDatabase
In: lib/application_database.rb

Mixin module: Tools to simplify interactions between Code Blue, MySQL, and ActiveRecord.

Note that the web server must be restarted to recognize changes within this file.

Methods

Public Instance methods

Extract the date portion from within a datetime string that is of the format: ‘YYYY-MM-DD HH:MM:SS‘

[Source]

    # File lib/application_database.rb, line 9
 9:   def to_datestamp
10:     self.to_mysql_datetime.split(' ')[0]
11:   end

Convert from Rails’ DateTime format to MySQL‘s datetime column data type format.

[Source]

    # File lib/application_database.rb, line 18
18:   def to_mysql_datetime
19:     subs =  []
20:     subs << ['T',       ' ']
21:     subs << [/-\d{4}$/, '' ]
22: 
23:     DateTime::parse(self.to_s).to_s.gsubs(subs)
24:   end

Convert a Rails’ DateTime value into a grammatically correct, human readable date.

[Source]

    # File lib/application_database.rb, line 39
39:   def to_readable_date
40:     self.strftime('%B %d, %Y')
41:   end

Convert a Rails’ DateTime value into RSS date format.

[Source]

    # File lib/application_database.rb, line 30
30:   def to_rss_time
31:     self.strftime('%a, %d %b %Y %H:%M:%S %Z')
32:   end

Convert from Rails’ DateTime format to a string of the format YEARMONTHDAY.

[Source]

    # File lib/application_database.rb, line 47
47:   def to_yyyymmdd 
48:     self.strftime('%Y%m%d')
49:   end

[Validate]