Class: Doing::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/doing/item.rb

Overview

This class describes a single WWID item

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

#idString (readonly)

Generate a hash that represents the entry

Returns:

#noteObject

Returns the value of attribute note.

#sectionObject

Returns the value of attribute section.

#titleObject

Returns the value of attribute title.

Instance Method Details

#end_dateTime

Get the value of the item's @done tag

Returns:

  • (Time)

    @done value

#equal?(other) ⇒ Boolean

Test for equality between items

Parameters:

  • other (Item)

    The other item

Returns:

  • (Boolean)

    is equal?

#intervalObject

Get the difference between the item's start date and the value of its @done tag (if present)

Returns:

  • Interval in seconds

#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

#overlapping_time?(item_b) ⇒ Boolean

Test if the interval between start date and @done value overlaps with another item's

Parameters:

  • item_b (Item)

    The item to compare

Returns:

  • (Boolean)

    overlaps?

#same_time?(item_b) ⇒ Boolean

Test if two items occur at the same time (same start date and equal duration)

Parameters:

  • item_b (Item)

    The item to compare

Returns:

  • (Boolean)

    is equal?

#search(search, distance: 3, negate: false, case_type: :smart, fuzzy: false) ⇒ Boolean

Test if item matches search string

Parameters:

  • search (String)

    The search string

  • negate (Boolean) (defaults to: false)

    negate results

  • case_type (Symbol) (defaults to: :smart)

    The case-sensitivity type (:sensitive, :ignore, :smart)

Returns:

  • (Boolean)

    matches search criteria

#should_finish?Boolean

Returns:

  • (Boolean)

#should_time?Boolean

Returns:

  • (Boolean)

#tag(tags, **options) ⇒ Object

Add (or remove) tags from the title of the item

Parameters:

  • tags (Array)

    The tags to apply

  • **options

    Additional options

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :date (Boolean)

    Include timestamp?

  • :single (Boolean)

    Log as a single change?

  • :value (String)

    A value to include as @tag(value)

  • :remove (Boolean)

    if true remove instead of adding

  • :rename_to (String)

    if not nil, rename target tag to this tag name

  • :regex (Boolean)

    treat target tag string as regex pattern

  • :force (Boolean)

    with rename_to, add tag if it doesn't exist

#tagsArray

Get a list of tags on the item

Returns:

  • (Array)

    array of tags (no values)

#tags?(tags, bool = :and, negate: false) ⇒ Boolean

Test if item contains tag(s)

Parameters:

  • tags (Array or String)

    The tags to test. Can be an array or a comma-separated string.

  • bool (Symbol) (defaults to: :and)

    The boolean to use for multiple tags (:and, :or, :not)

  • negate (Boolean) (defaults to: false)

    negate the result?

Returns:

  • (Boolean)

    true if tag/bool combination passes

#to_sObject

outputs item in Doing file format, including leading tab