Class: Evertils::Common::Entity::Notebooks
- Defined in:
- lib/evertils/common/entity/notebooks.rb
Overview
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #all ⇒ Object
- #create_from_yml(full_path) ⇒ Object
- #find_by_date_range(start, finish = DateTime.now, period = :created) ⇒ Object
Methods inherited from Base
#end_of_day, #initialize, #placeholders_for, #prop, #start_of_day, #symbolize_keys, #to_s
Methods inherited from Generic
#bytesize, #deprecation_notice, #encoding, #force_encoding, #has_required_fields, #initialize
Constructor Details
This class inherits a constructor from Evertils::Common::Entity::Base
Instance Method Details
#all ⇒ Object
7 8 9 |
# File 'lib/evertils/common/entity/notebooks.rb', line 7 def all @evernote.call(:listNotebooks) end |
#create_from_yml(full_path) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/evertils/common/entity/notebooks.rb', line 13 def create_from_yml(full_path) raise "File not found: #{full_path}" unless File.exist? full_path begin nb = Notebook.new conf = YAML::load(File.open(full_path)) required = %w(notebooks) if has_required_fields(conf, required) if !conf["notebooks"].nil? conf["notebooks"].each do |name| nb.create(name) end end else raise ArgumentError, 'Configuration file is missing some required fields' end rescue ArgumentError => e puts e. rescue Evernote::EDAM::Error::EDAMUserException => e puts e. end end |
#find_by_date_range(start, finish = DateTime.now, period = :created) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/evertils/common/entity/notebooks.rb', line 40 def find_by_date_range(start, finish = DateTime.now, period = :created) pool = all # method is serviceCreated/serviceUpdated period = "service#{period.to_s.capitalize_first_char}" pool.select do |book| f = finish.to_time.to_i s = start.to_time.to_i b = book_date(book, period).to_time.to_i b <= f && b >= s end end |