Class: Doing::Items

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

Overview

Items Array

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Array

#highlight_tags, #log_tags, #nested_hash, #to_tags, #to_tags!

Constructor Details

#initializeItems

Returns a new instance of Items.

Instance Attribute Details

#sectionsObject

Returns the value of attribute sections.

Instance Method Details

#add_section(section, log: false) ⇒ Object

Add a new section to the sections array. Accepts either a Section object, or a title string that will be converted into a Section.

Parameters:

  • section (Section)

    The section to add. A String value will be converted to Section automatically.

  • log (Boolean) (defaults to: false)

    Add a log message notifying the user about the creation of the section.

Returns:

  • nothing

#delete_item(item, single: false) ⇒ Object

Delete an item from the index

Parameters:

  • item

    The item

#in_section(section) ⇒ Items

Get a new Items object containing only items in a specified section

Parameters:

  • section (String)

    section title

Returns:

  • (Items)

    Array of items

#section?(section) ⇒ Boolean

Test if section already exists

Parameters:

  • section (String)

    section title

Returns:

  • (Boolean)

    true if section exists

#section_titlesArray

List sections, title only

Returns:

  • (Array)

    section titles

#to_sObject

Output sections and items in Doing file format

#update_item(old_item, new_item) ⇒ Object

Update an item in the index with a modified item

Parameters:

  • old_item

    The old item

  • new_item

    The new item

Raises:

  • (ItemNotFound)