Class: RubiGen::PathFilteredSource

Inherits:
PathSource show all
Defined in:
lib/rubigen/lookup.rb

Instance Attribute Summary collapse

Attributes inherited from PathSource

#path

Attributes inherited from Source

#label

Instance Method Summary collapse

Methods inherited from PathSource

#each

Methods inherited from Source

#each, #names

Constructor Details

#initialize(label, path, *filters) ⇒ PathFilteredSource

Returns a new instance of PathFilteredSource.



238
239
240
# File 'lib/rubigen/lookup.rb', line 238

def initialize(label, path, *filters)
  super label, File.join(path, "#{filter_str(filters)}generators")
end

Instance Attribute Details

#filtersObject (readonly)

Returns the value of attribute filters.



236
237
238
# File 'lib/rubigen/lookup.rb', line 236

def filters
  @filters
end

Instance Method Details

#==(source) ⇒ Object



250
251
252
# File 'lib/rubigen/lookup.rb', line 250

def ==(source)
  self.class == source.class && path == source.path && filters == source.filters && label == source.label
end

#filter_str(filters) ⇒ Object



242
243
244
245
246
247
248
# File 'lib/rubigen/lookup.rb', line 242

def filter_str(filters)
  @filters = filters.first.is_a?(Array) ? filters.first : filters
  return "" if @filters.blank?
  filter_str = @filters.map {|filter| "#{filter}_"}.join(",")
  filter_str += ","
  "{#{filter_str}}"
end