Sha256: 388a67a64297d59a5ea26ee6044c46d8299d81b8f599385566e2da84f4bfc113

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

module Evertils
  module Type
    class Daily < Type::Base
      NOTEBOOK = :Daily
      COLOUR = 0xffe8b7

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

        @title = @format.date_templates[NOTEBOOK]
        @content = @format.template_contents(NOTEBOOK)

        attach_pq_note if morning_note?
      end

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

      private

      #
      # TODO: refactor
      # @since 0.3.13
      def attach_pq_note
        @api = Evertils::Helper.load('ApiEnmlHandler', @config)
        enml = @api.from_str(@format.template_contents(NOTEBOOK))

        pq = @note_helper.wait_for(:'Priority Queue')

        xml_conf = {
          href: @note_helper.internal_url_for(pq.entity),
          content: @format.date_templates[:'Priority Queue']
        }

        xml = Evertils::Helper.load('Xml', enml)
        a = xml.create(:a, xml_conf)

        enml.at('li:contains("Queue") ul li').children.first.replace(a)
        @content = enml
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
evertils-0.3.21 lib/evertils/types/daily.rb
evertils-0.3.20 lib/evertils/types/daily.rb
evertils-0.3.19 lib/evertils/types/daily.rb
evertils-0.3.18 lib/evertils/types/daily.rb