Class: SmsBackupRenderer::BasePage

Inherits:
Object
  • Object
show all
Defined in:
lib/sms_backup_renderer/renderer.rb

Direct Known Subclasses

ConversationPage, IndexPage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output_file_path, assets_dir_path) ⇒ BasePage

Returns a new instance of BasePage.



13
14
15
16
# File 'lib/sms_backup_renderer/renderer.rb', line 13

def initialize(output_file_path, assets_dir_path)
  @output_file_path = output_file_path
  @assets_dir_path = assets_dir_path
end

Instance Attribute Details

#assets_dir_pathObject (readonly)

Returns the String path to the folder where static assets have been copied to.



11
12
13
# File 'lib/sms_backup_renderer/renderer.rb', line 11

def assets_dir_path
  @assets_dir_path
end

#output_file_pathObject (readonly)

Returns the String path to where this file will be written.



8
9
10
# File 'lib/sms_backup_renderer/renderer.rb', line 8

def output_file_path
  @output_file_path
end

Instance Method Details

#asset_path(filename) ⇒ Object



30
31
32
33
# File 'lib/sms_backup_renderer/renderer.rb', line 30

def asset_path(filename)
  Pathname.new(File.join(assets_dir_path, filename))
    .relative_path_from(Pathname.new(File.dirname(output_file_path))).to_s
end

#relative_path(path) ⇒ Object



26
27
28
# File 'lib/sms_backup_renderer/renderer.rb', line 26

def relative_path(path)
  Pathname.new(path).relative_path_from(Pathname.new(File.dirname(output_file_path))).to_s
end

#renderObject



18
19
20
# File 'lib/sms_backup_renderer/renderer.rb', line 18

def render
  ERB.new(File.read(File.join(File.dirname(__FILE__), 'templates', template_name))).result(binding)
end

#template_nameObject



35
36
37
# File 'lib/sms_backup_renderer/renderer.rb', line 35

def template_name
  raise 'not implemented'
end

#writeObject



22
23
24
# File 'lib/sms_backup_renderer/renderer.rb', line 22

def write
  File.write(output_file_path, render)
end