Sha256: b6c1c19e6a2740deedd4d79a1230252a3434cd323aa6e168f80bc10590e3ffe2

Contents?: true

Size: 1.21 KB

Versions: 16

Compression:

Stored size: 1.21 KB

Contents

module Evertils
  module Type
    class PriorityQueue < Type::Base
      NOTEBOOK = :'Priority Queue'
      COLOUR = 0xffe8b7

      #
      # @since 0.3.7
      def initialize(config, *args)
        super(config, *args)

        @title = @format.date_templates[NOTEBOOK]
        @content = find_previous
      end

      #
      # @since 0.3.9
      def tags
        [
          "day-#{Date.today.yday}",
          "week-#{Date.today.cweek}",
          "month-#{Date.today.month}"
        ]
      end

      private

      # Find a previous note
      # @since 0.3.7
      def find_previous
        day = Date.today
        note = nil

        Notify.info('Searching for last PQ...')

        (1..MAX_SEARCH_SIZE).each do |iter|
          day -= 1
          dow = @format.day_of_week(day.strftime('%a'))

          # always skip weekends, even if there is a note for those days
          next if %i[Sa Su].include?(dow)

          note_title = "Queue For [#{day.strftime('%B %-d')} - #{dow}]"
          note = @note_helper.model.find_note_contents(note_title).entity

          Notify.info(" (#{iter}) #{note_title}")

          break unless note.nil?
        end

        @api.convert_to_xml(note.content).prepare
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
evertils-1.0.12 lib/evertils/types/priority-queue.rb
evertils-1.0.11 lib/evertils/types/priority-queue.rb
evertils-1.0.10 lib/evertils/types/priority-queue.rb
evertils-1.0.9 lib/evertils/types/priority-queue.rb
evertils-1.0.8 lib/evertils/types/priority-queue.rb
evertils-1.0.7 lib/evertils/types/priority-queue.rb
evertils-1.0.6 lib/evertils/types/priority-queue.rb
evertils-1.0.5 lib/evertils/types/priority-queue.rb
evertils-1.0.4 lib/evertils/types/priority-queue.rb
evertils-1.0.3 lib/evertils/types/priority-queue.rb
evertils-1.0.2 lib/evertils/types/priority-queue.rb
evertils-1.0.1 lib/evertils/types/priority-queue.rb
evertils-1.0.0 lib/evertils/types/priority-queue.rb
evertils-0.4.0 lib/evertils/types/priority-queue.rb
evertils-0.3.27 lib/evertils/types/priority-queue.rb
evertils-0.3.26 lib/evertils/types/priority-queue.rb