Class: Everdone::TodoItem

Inherits:
Object
  • Object
show all
Defined in:
lib/everdone/todoItem.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, todoist_item, projects, labels) ⇒ TodoItem

Returns a new instance of TodoItem.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/everdone/todoItem.rb', line 22

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)
    item['labels'].each { |labelId|
        @labels.push(labels[labelId])
    }
    @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

Instance Attribute Details

#createdObject (readonly)

Returns the value of attribute created.



21
22
23
# File 'lib/everdone/todoItem.rb', line 21

def created
  @created
end

#due_dateObject (readonly)

Returns the value of attribute due_date.



21
22
23
# File 'lib/everdone/todoItem.rb', line 21

def due_date
  @due_date
end

#idObject (readonly)

Returns the value of attribute id.



21
22
23
# File 'lib/everdone/todoItem.rb', line 21

def id
  @id
end

#labelsObject (readonly)

Returns the value of attribute labels.



21
22
23
# File 'lib/everdone/todoItem.rb', line 21

def labels
  @labels
end

#notesObject (readonly)

Returns the value of attribute notes.



21
22
23
# File 'lib/everdone/todoItem.rb', line 21

def notes
  @notes
end

#priorityObject (readonly)

Returns the value of attribute priority.



21
22
23
# File 'lib/everdone/todoItem.rb', line 21

def priority
  @priority
end

#project_idsObject (readonly)

Returns the value of attribute project_ids.



21
22
23
# File 'lib/everdone/todoItem.rb', line 21

def project_ids
  @project_ids
end

#projectsObject (readonly)

Returns the value of attribute projects.



21
22
23
# File 'lib/everdone/todoItem.rb', line 21

def projects
  @projects
end

#titleObject (readonly)

Returns the value of attribute title.



21
22
23
# File 'lib/everdone/todoItem.rb', line 21

def title
  @title
end

Instance Method Details

#clean_titleObject



48
49
50
51
# 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) ⇒ Object



57
58
59
# File 'lib/everdone/todoItem.rb', line 57

def get_label_url(label)
    return @config.todoist_label_url + label
end

#get_project_url(project_index) ⇒ Object



53
54
55
# 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