Sha256: 2db902335198da1c2e7da2ee20c807b4216331d3b670f4c05c095547e1705af8

Contents?: true

Size: 809 Bytes

Versions: 3

Compression:

Stored size: 809 Bytes

Contents

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

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

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

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

      #
      # @since 0.3.7
      def should_create?
        is_monday = Date.today.monday?

        weekly_note_title = @format.date_templates[NOTEBOOK]
        found = @model.find_note_contents(weekly_note_title)
        result = found.entity.nil? && is_monday

        Notify.warning "#{self.class.name} skipped, note already exists" unless result

        result
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
evertils-0.3.14 lib/evertils/types/weekly.rb
evertils-0.3.13 lib/evertils/types/weekly.rb
evertils-0.3.12 lib/evertils/types/weekly.rb