Sha256: 46dcb864a22f048694fa5c77a1c545c78c8e5d4225c0a50d3a0e114908477136

Contents?: true

Size: 735 Bytes

Versions: 1

Compression:

Stored size: 735 Bytes

Contents

# frozen_string_literal: true

require 'tzinfo'

require 'whatup/server/models/application_record'

module Whatup
  module Server
    class Message < ApplicationRecord
      belongs_to :recipient, class_name: 'Client'
      belongs_to :sender, class_name: 'Client', foreign_key: 'sender_id'

      TZ = TZInfo::Timezone.get 'America/Detroit' # Central time

      def to_s
        <<~MSG.gsub '.exit', ''
          ------------------------------------------------------------
          From: #{sender.name}
          To: #{recipient.name}
          Date: #{TZ.utc_to_local(created_at).to_s :db}

          #{content&.chomp}
          ------------------------------------------------------------
        MSG
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whatup-0.3.5 lib/whatup/server/models/message.rb