This class represents the data type Interval.

Public Instance methods
escape( value )

Escapes value before storing to database. value can be either

  nil, resulting in 'NULL',
  String, which is escaped using Database#escape_string,
  or some Date-like format
# File lib/momomoto/datatype/interval.rb, line 12
      def escape( value )
        case value
          when nil then 'NULL'
          when String then "'#{Database.escape_string(value)}'"
          else "'#{Database.escape_string(value.strftime('%H:%M:%S'))}'"
filter_get( value )

Values are filtered by this method when getting them from database. Returns an instance of TimeInterval or nil if value is nil or empty. Raises ConversionError if the given value cannot be parsed.

# File lib/momomoto/datatype/interval.rb, line 24
      def filter_get( value )
        case value
          when nil, '' then nil
          when ::TimeInterval then value
          when String then ::TimeInterval.parse( value )
          else raise Error
       rescue => e
        raise ConversionError, "Error while parsing interval (#{e.message})"
filter_set( value )

Values are filtered by this function when being set. See Interval#filter_get

# File lib/momomoto/datatype/interval.rb, line 37
      def filter_set( value )
        filter_get( value )