Class: Todoist::Project

Inherits:
Struct
  • Object
show all
Includes:
StructCleanup
Defined in:
lib/todoist/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from StructCleanup

#fields_to_date_time, #ignore_undefined_keys, #properties_to_desc, #replace_keys

Constructor Details

#initialize(*arg_hashes) ⇒ Project

Returns a new instance of Project.



33
34
35
36
37
38
39
# File 'lib/todoist/project.rb', line 33

def initialize(*arg_hashes)
  args = arg_hashes.first
  fields_to_date_time(args, %w[created_at updated_at])
  ignore_undefined_keys(args)
  get_root_name(args)
  super
end

Instance Attribute Details

#accessObject

Returns the value of attribute access

Returns:

  • (Object)

    the current value of access



2
3
4
# File 'lib/todoist/project.rb', line 2

def access
  @access
end

#can_assign_tasksObject

Returns the value of attribute can_assign_tasks

Returns:

  • (Object)

    the current value of can_assign_tasks



2
3
4
# File 'lib/todoist/project.rb', line 2

def can_assign_tasks
  @can_assign_tasks
end

#child_orderObject Also known as: order

Returns the value of attribute child_order

Returns:

  • (Object)

    the current value of child_order



2
3
4
# File 'lib/todoist/project.rb', line 2

def child_order
  @child_order
end

#colorObject

Returns the value of attribute color

Returns:

  • (Object)

    the current value of color



2
3
4
# File 'lib/todoist/project.rb', line 2

def color
  @color
end

#created_atObject

Returns the value of attribute created_at

Returns:

  • (Object)

    the current value of created_at



2
3
4
# File 'lib/todoist/project.rb', line 2

def created_at
  @created_at
end

#creator_uidObject

Returns the value of attribute creator_uid

Returns:

  • (Object)

    the current value of creator_uid



2
3
4
# File 'lib/todoist/project.rb', line 2

def creator_uid
  @creator_uid
end

#default_orderObject

Returns the value of attribute default_order

Returns:

  • (Object)

    the current value of default_order



2
3
4
# File 'lib/todoist/project.rb', line 2

def default_order
  @default_order
end

#descriptionObject

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



2
3
4
# File 'lib/todoist/project.rb', line 2

def description
  @description
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



2
3
4
# File 'lib/todoist/project.rb', line 2

def id
  @id
end

#inbox_projectObject

Returns the value of attribute inbox_project

Returns:

  • (Object)

    the current value of inbox_project



2
3
4
# File 'lib/todoist/project.rb', line 2

def inbox_project
  @inbox_project
end

#is_archivedObject

Returns the value of attribute is_archived

Returns:

  • (Object)

    the current value of is_archived



2
3
4
# File 'lib/todoist/project.rb', line 2

def is_archived
  @is_archived
end

#is_collapsedObject

Returns the value of attribute is_collapsed

Returns:

  • (Object)

    the current value of is_collapsed



2
3
4
# File 'lib/todoist/project.rb', line 2

def is_collapsed
  @is_collapsed
end

#is_deletedObject

Returns the value of attribute is_deleted

Returns:

  • (Object)

    the current value of is_deleted



2
3
4
# File 'lib/todoist/project.rb', line 2

def is_deleted
  @is_deleted
end

#is_favoriteObject

Returns the value of attribute is_favorite

Returns:

  • (Object)

    the current value of is_favorite



2
3
4
# File 'lib/todoist/project.rb', line 2

def is_favorite
  @is_favorite
end

#is_frozenObject

Returns the value of attribute is_frozen

Returns:

  • (Object)

    the current value of is_frozen



2
3
4
# File 'lib/todoist/project.rb', line 2

def is_frozen
  @is_frozen
end

#is_sharedObject

Returns the value of attribute is_shared

Returns:

  • (Object)

    the current value of is_shared



2
3
4
# File 'lib/todoist/project.rb', line 2

def is_shared
  @is_shared
end

#jsw_ignored_keysObject

Returns the value of attribute jsw_ignored_keys

Returns:

  • (Object)

    the current value of jsw_ignored_keys



2
3
4
# File 'lib/todoist/project.rb', line 2

def jsw_ignored_keys
  @jsw_ignored_keys
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



2
3
4
# File 'lib/todoist/project.rb', line 2

def name
  @name
end

#p_numObject

Returns the value of attribute p_num

Returns:

  • (Object)

    the current value of p_num



2
3
4
# File 'lib/todoist/project.rb', line 2

def p_num
  @p_num
end

#parent_idObject

Returns the value of attribute parent_id

Returns:

  • (Object)

    the current value of parent_id



2
3
4
# File 'lib/todoist/project.rb', line 2

def parent_id
  @parent_id
end

#public_accessObject

Returns the value of attribute public_access

Returns:

  • (Object)

    the current value of public_access



2
3
4
# File 'lib/todoist/project.rb', line 2

def public_access
  @public_access
end

#roleObject

Returns the value of attribute role

Returns:

  • (Object)

    the current value of role



2
3
4
# File 'lib/todoist/project.rb', line 2

def role
  @role
end

#root_nameObject

Returns the value of attribute root_name

Returns:

  • (Object)

    the current value of root_name



2
3
4
# File 'lib/todoist/project.rb', line 2

def root_name
  @root_name
end

#updated_atObject

Returns the value of attribute updated_at

Returns:

  • (Object)

    the current value of updated_at



2
3
4
# File 'lib/todoist/project.rb', line 2

def updated_at
  @updated_at
end

#view_styleObject

Returns the value of attribute view_style

Returns:

  • (Object)

    the current value of view_style



2
3
4
# File 'lib/todoist/project.rb', line 2

def view_style
  @view_style
end

Instance Method Details

#archived?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/todoist/project.rb', line 71

def archived?
  is_archived.present?
end

#collapsedObject



75
76
77
# File 'lib/todoist/project.rb', line 75

def collapsed
  is_collapsed.present?
end

#deleted?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/todoist/project.rb', line 79

def deleted?
  is_deleted.present?
end

#favorite?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/todoist/project.rb', line 83

def favorite?
  is_favorite.present?
end

#frozen?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/todoist/project.rb', line 87

def frozen?
  is_frozen.present?
end

#get_root_name(args) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/todoist/project.rb', line 41

def get_root_name(args)
  if (m = args["name"].match(/(?<root>.*?)\s*(?<num>\d)*\s*$/))
    args[:root_name] = m[:root].downcase
    args[:p_num] = [m[:num].to_i, 1].max
  else
    args[:root_name] = args["name"]
    args[:p_num] = 1
  end
end

#inbox?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/todoist/project.rb', line 91

def inbox?
  inbox_project.present?
end

#inspect(short_view: true) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/todoist/project.rb', line 51

def inspect(short_view: true)
  if short_view
    {name: name, id: id, root_name: root_name, p_num: p_num}
  else
    super()
  end
end

#rules(td_client) ⇒ Object



61
62
63
64
65
66
67
68
69
# File 'lib/todoist/project.rb', line 61

def rules(td_client)
  r = td_client.tasks.find { |t| t.project_id == id && t.content == "PROJECT RULES" }
  return if r.nil?
  begin
    JSON.parse(r.description)
  rescue
    nil
  end
end

#shared?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/todoist/project.rb', line 95

def shared?
  is_shared.present?
end

#urlObject



99
100
101
# File 'lib/todoist/project.rb', line 99

def url
  "https://todoist.com/showProject?id=#{id}"
end