Sha256: b76ea99c24c89ecf83c5ee77352afdfcfd49bdd49851d6ec6741e33cbd013530

Contents?: true

Size: 814 Bytes

Versions: 2

Compression:

Stored size: 814 Bytes

Contents

# frozen_string_literal: true

module Evertils
  module Action
    class DuplicatePrevious < Action::Base
      def initialize(args)
        super(args)

        @args[:content] = find_previous

        query = Evertils::Common::Query::Simple.new
        query.create_note_from_hash(@args)
      end

      private

      def find_previous
        helper = Evertils::Helper::Note.instance
        note = helper.wait_for_with_grammar(grammar)

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

      def grammar
        terms = Grammar.new
        terms.notebook = @args[:notebook]
        terms.tags = {
          day: Date.today.yday,
          week: Date.today.cweek
        }
        terms.created = Date.new(Date.today.year, 1, 1).strftime('%Y%m%d')
        terms
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
evertils-2.0.2 lib/evertils/actions/duplicate_previous.rb
evertils-2.0.1 lib/evertils/actions/duplicate_previous.rb