Class: TaskWarrior::Tag

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/taskwarrior/tag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag_or_name, tasks = []) ⇒ Tag

Returns a new instance of Tag.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/taskwarrior/tag.rb', line 11

def initialize(tag_or_name, tasks = [])
  if tag_or_name.respond_to?(:name)
    @name = tag_or_name.name
    @tasks = tag_or_name.tasks
  else
    @name = tag_or_name
    @tasks = []
  end

  tasks.each{|task|
    self << task
  }
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/taskwarrior/tag.rb', line 5

def name
  @name
end

Instance Method Details

#<<(task) ⇒ Object



25
26
27
# File 'lib/taskwarrior/tag.rb', line 25

def <<(task)
  @tasks << task unless @tasks.include?(task)
end

#==(other) ⇒ Object



37
38
39
# File 'lib/taskwarrior/tag.rb', line 37

def ==(other)
  name == other.name
end

#tasksObject



29
30
31
# File 'lib/taskwarrior/tag.rb', line 29

def tasks
  @tasks
end

#to_sObject



33
34
35
# File 'lib/taskwarrior/tag.rb', line 33

def to_s
  "Tag: #{name} (#{@tasks.size} tasks)"
end