Class: Lifer::Selection

Inherits:
Collection
  • Object
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 provide 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

Class Method Summary collapse

Instance Method Summary collapse

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
30
31
# File 'lib/lifer/selection.rb', line 27

def generate
  selection = new(name: name, directory: nil)
  Lifer.register_settings name
  selection
end

Instance Method Details

#entriesObject

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

Raises:

  • (NotImplementedError)


49
50
51
# File 'lib/lifer/selection.rb', line 49

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).



62
63
64
# File 'lib/lifer/selection.rb', line 62

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