Class: Lifer::Selection

Inherits:
Collection show all
Defined in:
lib/lifer/selection.rb

Overview

A selection is a group of entries that belong to any collection. Lifer includes some selection classes by default, but the intent here is to let users bring their own selections.

A selection subclass can be added to the Lifer project as a Ruby file. Any detected Ruby files are dynamically loaded when ‘Lifer::Brain` is initialized.

Implementing a selection is simple. Just implement the ‘#entries` method and rovide a name. The `#entries` method can be used to filter down `Lifer.entry_manifest` in whichever way one needs. To see examples of this, check out the source code of any of the included selections.

Direct Known Subclasses

AllMarkdown, IncludedInFeeds

Defined Under Namespace

Classes: AllMarkdown, IncludedInFeeds

Class Attribute Summary collapse

Attributes inherited from Collection

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Collection

#root?

Class Attribute Details

.nameObject

Returns the value of attribute name.



15
16
17
# File 'lib/lifer/selection.rb', line 15

def name
  @name
end

Class Method Details

.generateLifer::Selection

The constructor method for selections. Unlike collections:

1. Selections never have a unique instance name. (There is only one
   instance of each selection, and it's inherited from the class.)
2. Selections never have a directory. Selections are virtual,
   pseudo-collections that paste together entries across collections.

Thus, the generator method here takes no arguments.

Returns:



27
28
29
# File 'lib/lifer/selection.rb', line 27

def generate
  new(name: name, directory: nil)
end

Instance Method Details

#entriesObject

The ‘#entries` method should be implemented on every selection subclass.

Raises:

  • (NotImplementedError)


47
48
49
# File 'lib/lifer/selection.rb', line 47

def entries
  raise NotImplementedError, I18n.t("selection.entries_not_implemented")
end

#settingString, ...

A getter for selection settings. See ‘Lifer::Collection#setting` for more information.

Returns:

  • (String, Symbol, NilClass)

    The setting for the collection (or a fallback setting, or a default setting).



60
61
62
# File 'lib/lifer/selection.rb', line 60

def setting(...)
  super(...)
end