Sha256: 7a3bad07ab9d4e33f47a2c8a113a7a11596359aa24436c1c3b2f9a489cb2eb7c

Contents?: true

Size: 817 Bytes

Versions: 2

Compression:

Stored size: 817 Bytes

Contents

# frozen_string_literal: true

module Google
  module Apis
    module CalendarV3
      class Event
        MEETING_URL_REGEX = %r{https://.*\.zoom\.us/j/\d+}
        include ActionView::Helpers::DateHelper

        def meeting_url
          matches = (location + description).match(MEETING_URL_REGEX)
          matches[0] if matches
        end

        def already_started?
          start.date_time <= DateTime.now
        end

        def more_than_five_minutes_from_now?
          start.date_time.to_time >= (DateTime.now.to_time + 5 * 60)
        end

        def start_time_in_words
          distance = time_ago_in_words(start.date_time)
          if already_started?
            "#{distance} ago".bold.red
          else
            "in #{distance}".bold
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zoom_launcher-0.1.1 lib/google/apis/calendar_v3/event.rb
zoom_launcher-0.1.0 lib/google/apis/calendar_v3/event.rb