Sha256: 4db48be0f2f95ca4374e49a5f6dab47b5289d1bad6a13480f049722ed47d4632

Contents?: true

Size: 817 Bytes

Versions: 5

Compression:

Stored size: 817 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.to_h)
      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

5 entries across 5 versions & 1 rubygems

Version Path
evertils-2.2.3 lib/evertils/actions/duplicate_previous.rb
evertils-2.2.2 lib/evertils/actions/duplicate_previous.rb
evertils-2.2.1 lib/evertils/actions/duplicate_previous.rb
evertils-2.2.0 lib/evertils/actions/duplicate_previous.rb
evertils-2.1.0 lib/evertils/actions/duplicate_previous.rb