Class: RGovData::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/rgovdata/data/template.rb

Overview

This is a convenience class for accessing disk-based template files It avoids pathname processing from being required where template are used

Class Method Summary collapse

Class Method Details

.get(name, realm = nil) ⇒ Object

Returns the template file content name is the filename realm if specified is the subdirectory



21
22
23
24
25
# File 'lib/rgovdata/data/template.rb', line 21

def get(name, realm = nil)
  IO.read(path(name, realm))
rescue
  nil
end

.path(name, realm = nil) ⇒ Object

Returns the template file path name is the filename realm if specified is the subdirectory



11
12
13
14
15
16
# File 'lib/rgovdata/data/template.rb', line 11

def path(name, realm = nil)
  extra_path = [realm,name].compact.map(&:to_s)
  Pathname.new(File.dirname(__FILE__)).join(*extra_path).to_s
rescue
  nil
end