class RubiGen::Source

Sources enumerate (yield from each) generator specs which describe where to find and how to create generators. Enumerable is mixed in so, for example, source.collect will retrieve every generator. Sources may be assigned a label to distinguish them.

Attributes

label[R]

Public Class Methods

new(label) click to toggle source
# File lib/rubigen/lookup.rb, line 189
def initialize(label)
  @label = label
end

Public Instance Methods

each() click to toggle source

The each method must be implemented in subclasses. The base implementation raises an error.

# File lib/rubigen/lookup.rb, line 195
def each
  raise NotImplementedError
end
names(filter = nil) click to toggle source

Return a convenient sorted list of all generator names.

# File lib/rubigen/lookup.rb, line 200
def names(filter = nil)
  inject([]) do |mem, spec|
    case filter
    when :visible
      mem << spec.name if spec.visible?
    end
    mem
  end.sort
end