Class: Glue::Template::Meta

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Meta

Returns a new instance of Meta.



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

def initialize(path)
  self.data = {}
  self.body = File.read(path)
  process!
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



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

def body
  @body
end

#contentObject

Returns the value of attribute content.



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

def content
  @content
end

#dataObject

Returns the value of attribute data.



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

def data
  @data
end

Instance Method Details

#process!Object



14
15
16
17
18
19
20
21
# File 'lib/glue/template/meta.rb', line 14

def process!
  self.content = body.gsub /^\/ *(.*?): *(.*?) *$/sm do |m|
    data[$1] = $2
    ""
  end
  
  self.data.symbolize_keys!
end