Class: LegalBeagle::Converter

Inherits:
Object
  • Object
show all
Includes:
Jekyll::Convertible
Defined in:
lib/legal_beagle/converter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Converter

Returns a new instance of Converter.



11
12
13
14
15
16
# File 'lib/legal_beagle/converter.rb', line 11

def initialize(filename)
  file = Pathname.new(filename)
  self.ext     = file.extname
  self.content = file.read
  read_yaml(file.dirname, file.basename)
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



9
10
11
# File 'lib/legal_beagle/converter.rb', line 9

def content
  @content
end

#dataObject

Returns the value of attribute data.



9
10
11
# File 'lib/legal_beagle/converter.rb', line 9

def data
  @data
end

#extObject

Returns the value of attribute ext.



9
10
11
# File 'lib/legal_beagle/converter.rb', line 9

def ext
  @ext
end

Instance Method Details

#render(pdf) ⇒ Object



22
23
24
25
26
# File 'lib/legal_beagle/converter.rb', line 22

def render(pdf)
  @pdf = pdf
  self.content = Liquid::Template.parse(self.content).render(data, {})
  self.transform
end

#transformObject



18
19
20
# File 'lib/legal_beagle/converter.rb', line 18

def transform
  Maruku.new(content).to_prawn(@pdf)
end