Sha256: d6a25f55746892345102d266c078cde83b3404d4599d77eb840707691dd4c0bf

Contents?: true

Size: 1.52 KB

Versions: 20

Compression:

Stored size: 1.52 KB

Contents

require 'evertils/common/entity/notebooks'

module Evertils
  module Common
    module Entity
      class Notebook < Entity::Base
        #
        # @since 0.2.0
        def find(name)
          @entity = nil
          notebooks = Notebooks.new.all

          @entity = notebooks.detect { |nb| nb.name == name }

          self if @entity
        end

        #
        # @since 0.2.0
        def create(name, stack = nil)
          @entity = nil

          notebook = ::Evernote::EDAM::Type::Notebook.new
          notebook.name = name

          if !stack.nil?
            notebook.stack = stack
            notebook.name = "#{stack}/#{name}"
          end

          @entity = @evernote.call(:createNotebook, notebook)

          self if @entity
        end

        #
        # @since 0.2.0
        def default
          @entity = @evernote.call(:getDefaultNotebook)

          self if @entity
        end

        #
        # @since 0.2.9
        def expunge!
          @evernote.call(:expungeNotebook, @entity.guid)
        end

        #
        # @since 0.2.0
        # @deprecated 0.2.9
        def expunge
          deprecation_notice('0.2.9', 'Replaced with Entity#expunge!  Will be removed in 0.4.0.')

          @evernote.call(:expungeNotebook, @entity.guid)
        end

        #
        # @since 0.2.0
        def notes
          filter = ::Evernote::EDAM::NoteStore::NoteFilter.new
          filter.notebookGuid = @entity.guid

          notes = Notes.new
          notes.find(nil, @entity.guid)
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
evertils-common-0.3.18 lib/evertils/common/entity/notebook.rb
evertils-common-0.3.17 lib/evertils/common/entity/notebook.rb
evertils-common-0.3.16 lib/evertils/common/entity/notebook.rb
evertils-common-0.3.15 lib/evertils/common/entity/notebook.rb
evertils-common-0.3.14 lib/evertils/common/entity/notebook.rb
evertils-common-0.3.13 lib/evertils/common/entity/notebook.rb
evertils-common-0.3.12 lib/evertils/common/entity/notebook.rb
evertils-common-0.3.11 lib/evertils/common/entity/notebook.rb
evertils-common-0.3.10 lib/evertils/common/entity/notebook.rb
evertils-common-0.3.9 lib/evertils/common/entity/notebook.rb
evertils-common-0.3.8 lib/evertils/common/entity/notebook.rb
evertils-common-0.3.7 lib/evertils/common/entity/notebook.rb
evertils-common-0.3.6 lib/evertils/common/entity/notebook.rb
evertils-common-0.3.5 lib/evertils/common/entity/notebook.rb
evertils-common-0.3.4.1 lib/evertils/common/entity/notebook.rb
evertils-common-0.3.4 lib/evertils/common/entity/notebook.rb
evertils-common-0.3.4.1.pre.dev lib/evertils/common/entity/notebook.rb
evertils-common-0.3.3.1 lib/evertils/common/entity/notebook.rb
evertils-common-0.3.3 lib/evertils/common/entity/notebook.rb
evertils-common-0.3.2 lib/evertils/common/entity/notebook.rb