Class: TaskWarrior::Tag
- Inherits:
-
Object
- Object
- TaskWarrior::Tag
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/taskwarrior/tag.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #<<(task) ⇒ Object
- #==(other) ⇒ Object
-
#initialize(tag_or_name, tasks = []) ⇒ Tag
constructor
A new instance of Tag.
- #tasks ⇒ Object
- #to_s ⇒ Object
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
#name ⇒ Object (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 |
#tasks ⇒ Object
29 30 31 |
# File 'lib/taskwarrior/tag.rb', line 29 def tasks @tasks end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/taskwarrior/tag.rb', line 33 def to_s "Tag: #{name} (#{@tasks.size} tasks)" end |