Class: Everdone::TodoItem
- Inherits:
-
Object
- Object
- Everdone::TodoItem
- Defined in:
- lib/everdone/todoItem.rb
Instance Attribute Summary collapse
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#due_date ⇒ Object
readonly
Returns the value of attribute due_date.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#labels ⇒ Object
readonly
Returns the value of attribute labels.
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#project_ids ⇒ Object
readonly
Returns the value of attribute project_ids.
-
#projects ⇒ Object
readonly
Returns the value of attribute projects.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #clean_title ⇒ Object
- #get_label_url(label) ⇒ Object
- #get_project_url(project_index) ⇒ Object
-
#initialize(config, todoist_item, projects, labels) ⇒ TodoItem
constructor
A new instance of TodoItem.
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
#created ⇒ Object (readonly)
Returns the value of attribute created.
21 22 23 |
# File 'lib/everdone/todoItem.rb', line 21 def created @created end |
#due_date ⇒ Object (readonly)
Returns the value of attribute due_date.
21 22 23 |
# File 'lib/everdone/todoItem.rb', line 21 def due_date @due_date end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
21 22 23 |
# File 'lib/everdone/todoItem.rb', line 21 def id @id end |
#labels ⇒ Object (readonly)
Returns the value of attribute labels.
21 22 23 |
# File 'lib/everdone/todoItem.rb', line 21 def labels @labels end |
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
21 22 23 |
# File 'lib/everdone/todoItem.rb', line 21 def notes @notes end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
21 22 23 |
# File 'lib/everdone/todoItem.rb', line 21 def priority @priority end |
#project_ids ⇒ Object (readonly)
Returns the value of attribute project_ids.
21 22 23 |
# File 'lib/everdone/todoItem.rb', line 21 def project_ids @project_ids end |
#projects ⇒ Object (readonly)
Returns the value of attribute projects.
21 22 23 |
# File 'lib/everdone/todoItem.rb', line 21 def projects @projects end |
#title ⇒ Object (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_title ⇒ Object
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 |