Class: Doing::Item

Inherits:
Object show all
Includes:
Color, ItemDates, ItemQuery, ItemState, ItemTags
Defined in:
lib/doing/item/item.rb

Overview

This class describes a single WWID item

Constant Summary

Constants included from Color

Color::ATTRIBUTES, Color::ATTRIBUTE_NAMES, Color::COLORED_REGEXP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Color

#attributes, coloring?, #support?, template, #uncolor

Methods included from ItemTags

#tag, #tag_array, #tags, #tags_with_values

Methods included from ItemState

#finished?, #should_finish?, #should_time?, #unfinished?

Methods included from ItemQuery

#highlight_search, #ignore_case, #search, #tag_values?, #tags?

Methods included from ItemDates

#calculate_end_date, #duration, #end_date, #expand_date_tags, #interval, #overlapping_time?, #same_time?

Constructor Details

#initialize(date, title, section, note = nil) ⇒ Item

Initialize an item with date, title, section, and optional note

Parameters:

  • date (Time)

    The item's start date

  • title (String)

    The title

  • section (String)

    The section to which the item belongs

  • note (Array or String) (defaults to: nil)

    The note (optional)

Instance Attribute Details

#dateObject

Returns the value of attribute date.

#noteObject

Returns the value of attribute note.

#sectionObject

Returns the value of attribute section.

#titleObject

Returns the value of attribute title.

Instance Method Details

#cloneObject

#equal?(other, match_section: false) ⇒ Boolean

Test for equality between items

Parameters:

  • other (Item)

    The other item

  • match_section (Boolean) (defaults to: false)

    If true, require item sections to match

Returns:

  • (Boolean)

    is equal?

#idString

Generate a hash that represents the entry

Returns:

#move_to(new_section, label: true, log: true) ⇒ Object

Move item from current section to destination section

Parameters:

  • new_section (String)

    The destination section

  • label (Boolean) (defaults to: true)

    add @from(original section) tag

  • log (Boolean) (defaults to: true)

    log this action

Returns:

  • nothing

#to_pretty(elements: %i[date title section]) ⇒ Object

outputs a colored string with relative date and highlighted tags

Returns:

  • Pretty representation of the object.

#to_sObject

outputs item in Doing file format, including leading tab