class TodoistQuerynaut::Client
Public Class Methods
new(todoist)
click to toggle source
# File lib/todoist_querynaut/client.rb, line 3 def initialize(todoist) @todoist = todoist end
Public Instance Methods
all_items()
click to toggle source
# File lib/todoist_querynaut/client.rb, line 19 def all_items search "view all" end
project_name_to_id(name)
click to toggle source
# File lib/todoist_querynaut/client.rb, line 23 def project_name_to_id(name) projects = all_projects.select{|p| p["name"].casecmp(name) == 0} raise ProjectNotFoundError if projects.empty? projects.first["id"].to_i end
run(query)
click to toggle source
# File lib/todoist_querynaut/client.rb, line 7 def run(query) TodoistQuerynaut::Parser.parse(query).run_query self end
search(query)
click to toggle source
# File lib/todoist_querynaut/client.rb, line 11 def search(query) # Todoist doesn't always set "query" on the results, hence we cannot # search(value)[value] here, as ruby-todoist-api Gem then assigns "nil" # as the hash's key. Instead we do .first.last, to get the value of the # first hash entry @todoist.query.search(query).first.last.data end
Private Instance Methods
all_projects()
click to toggle source
# File lib/todoist_querynaut/client.rb, line 31 def all_projects() @projects ||= @todoist.projects.retrieve(["projects"])["projects"] end