class Evertils::Common::Entity::Base

Constants

REPLACEMENTS

Attributes

entity[RW]

Public Class Methods

new() click to toggle source
Calls superclass method Evertils::Common::Generic::new
# File lib/evertils/common/entity.rb, line 20
def initialize
  @evernote = Authentication.instance

  super
end

Public Instance Methods

end_of_day(date = ::Time.now) click to toggle source

@since 0.2.8

# File lib/evertils/common/entity.rb, line 60
def end_of_day(date = ::Time.now)
  ::Time.mktime(date.year, date.month, date.day, 23, 59, 59, 0).to_datetime
end
placeholders_for(items) click to toggle source
# File lib/evertils/common/entity.rb, line 26
def placeholders_for(items)
  items.map do |item|
    REPLACEMENTS.each_pair do |k, v|
      item.last.gsub!(k.to_s, v.to_s) if item.last.is_a? String
      item.last.map { |i| i.gsub!(k.to_s, v.to_s) } if item.last.is_a? Array
    end
  end

  symbolize_keys(items)
end
prop(name) click to toggle source

@since 0.2.9

# File lib/evertils/common/entity.rb, line 66
def prop(name)
  @entity.send(name)
end
start_of_day(date = ::Time.now) click to toggle source

@since 0.2.8

# File lib/evertils/common/entity.rb, line 54
def start_of_day(date = ::Time.now)
  ::Time.mktime(date.year, date.month, date.day, 12, 0, 0, 0, 0).to_datetime
end
symbolize_keys(hash) click to toggle source
# File lib/evertils/common/entity.rb, line 37
def symbolize_keys(hash)
  hash.inject({}){ |result, (key, value)|
    new_key = case key
              when String then key.to_sym
              else key
              end
    new_value = case value
                when Hash then symbolize_keys(value)
                else value
                end
    result[new_key] = new_value
    result
  }
end
to_s() click to toggle source

@since 0.3.2

# File lib/evertils/common/entity.rb, line 72
def to_s
  prop(:guid)
end