Class: Glue::Template::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/glue/template/base.rb

Direct Known Subclasses

Feed, Sitemap

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Base

Returns a new instance of Base.



8
9
10
11
12
# File 'lib/glue/template/base.rb', line 8

def initialize(config)
  self.config = config
  self.items = []
  self.filters = []
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



5
6
7
# File 'lib/glue/template/base.rb', line 5

def config
  @config
end

#filtersObject

Returns the value of attribute filters.



6
7
8
# File 'lib/glue/template/base.rb', line 6

def filters
  @filters
end

#itemsObject

Returns the value of attribute items.



4
5
6
# File 'lib/glue/template/base.rb', line 4

def items
  @items
end

Instance Method Details

#<<(options) ⇒ Object



14
15
16
# File 'lib/glue/template/base.rb', line 14

def <<(options)
  self.items << options
end

#apply_filtersObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/glue/template/base.rb', line 18

def apply_filters
  filtered_items = []
  
  items.each do |options|
    filters.collect do |f|
      r = Regexp.new(f, Regexp::MULTILINE|Regexp::EXTENDED|Regexp::IGNORECASE)
      filtered_items << options and break if options[:path] =~ r
    end
  end

  filtered_items
end

#save(path) ⇒ Object



31
32
33
# File 'lib/glue/template/base.rb', line 31

def save(path)
  raise "This is an abstract method; override it!"
end