Sha256: 9067d6acaeec8396037ed5f70a2357c61b248d8be52e557c0bd4bea11afa5ed9

Contents?: true

Size: 1.65 KB

Versions: 1

Compression:

Stored size: 1.65 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

          notebooks.each do |notebook|
            if notebook.name == name.to_s
              @entity = notebook
            end
          end

          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')

          @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(@evernote)
          notes.find(nil, @entity.guid)
        end

        #
        # @since 0.3.0
        def entity
          @entity
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
evertils-common-0.3.0 lib/evertils/common/entity/notebook.rb