class Everdone::TodoItem

Attributes

created[R]
due_date[R]
id[R]
labels[R]
notes[R]
priority[R]
project_ids[R]
projects[R]
title[R]

Public Class Methods

new(config, todoist_item, projects, labels) click to toggle source
# File lib/everdone/todoItem.rb, line 20
def initialize(config, todoist_item, projects, labels)
    @config = config
    item = todoist_item
    @id = item['id']
    @title = item['content']
    clean_title()  # strip off all (known) Todoist detritus
    @created = item['completed_date']
    @projects = []  # Just the parent for now.  TODO: array of projects starting with senior parent and working down to immediate parent
    @projects.push(projects[item['project_id']])
    @project_ids = []  # Just the parent for now.  TODO: array of project ids starting with senior... (see above)
    @project_ids.push(item['project_id'])
    @labels = []  # arrary of associated labels (random order)
    if not item['labels'].nil?
        item['labels'].each { |labelId|
            @labels.push(labels[labelId])
        }
    end
    @priority = item['priority']
    @due_date = item['due_date']
    @notes = []  # array of notes
    if not item['notes'].nil?
        item['notes'].each { |note|
            new_note = TodoNote.new(note)
            @notes.push(new_note)
        }
    end
end

Public Instance Methods

clean_title() click to toggle source
# File lib/everdone/todoItem.rb, line 48
def clean_title()
    cleaned_title = @title.match(@config.todoist_link_title_regex)
    @title = cleaned_title.nil? ? @title : cleaned_title[1].strip
end
get_label_url(label) click to toggle source
# File lib/everdone/todoItem.rb, line 57
def get_label_url(label)
    return @config.todoist_label_url + label
end
get_project_url(project_index) click to toggle source
# File lib/everdone/todoItem.rb, line 53
def get_project_url(project_index)
    return @config.todoist_project_url + @project_ids[project_index].to_s
end