Method: Doing::Items#in_section

Defined in:
lib/doing/items/filter.rb

#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



12
13
14
15
16
17
18
19
20
21
# File 'lib/doing/items/filter.rb', line 12

def in_section(section)
  sect = section.is_a?(Section) ? section.title : section
  if sect =~ /^all$/i
    dup
  else
    items = Items.new.concat(select { |item| !item.nil? && item.section == section })
    items.add_section(section, log: false)
    items
  end
end