class Log4ever::Tag

Public Class Methods

new(note, auth_store) click to toggle source
# File lib/log4r/evernote.rb, line 235
def initialize(note, auth_store)
  @note = note
  @auth_store = auth_store
end

Public Instance Methods

get() click to toggle source

get tag objects

# File lib/log4r/evernote.rb, line 247
def get
  return if @list.nil? || @list.empty?
  return @tag_guids unless @tag_guids.nil?
  @list = [@list] unless @list.kind_of?(Array)
  @tags = @auth_store.note_store.listTags(@auth_store.auth_token) if @tags.nil?
  @tag_guids = @list.map do |tag|
    tag_obj = to_obj(tag) || create(tag)
    tag_obj.guid
  end
end
names=(list) click to toggle source

set tag list

# File lib/log4r/evernote.rb, line 241
def names=(list)
  @list = list
  @tag_guids = nil
end

Private Instance Methods

create(tag_name) click to toggle source

create tag object

# File lib/log4r/evernote.rb, line 260
def create(tag_name)
  tag = ::Evernote::EDAM::Type::Tag.new
  tag.name = tag_name
  tag_obj = @auth_store.note_store.createTag(@auth_store.auth_token, tag)
  Log4r::Logger.log_internal { "Create tag: #{tag_name}" }
  tag_obj
end
to_obj(tag_name) click to toggle source

tag name to tag object

# File lib/log4r/evernote.rb, line 269
def to_obj(tag_name)
  @tags.each do |tag|
    if tag_name == tag.name
      Log4r::Logger.log_internal { "Get tag: #{tag_name}" }
      return tag
    end
  end
  nil
end