class SimpleCV::Basic
Attributes
config[R]
Public Class Methods
new(config_path: @config = build_struct_tree parse_config_file config_path)
click to toggle source
# File lib/simple_cv/basic.rb, line 10 def initialize config_path: @config = build_struct_tree parse_config_file config_path end
Public Instance Methods
render_file(filename: "SimpleCV", path: nil)
click to toggle source
Render file
With given path and filename, pdf can be rendered to a specific location. If no arguments are given, filename will be set to SimpleCV.pdf and pdf will be rendered to current working dir.
# File lib/simple_cv/basic.rb, line 20 def render_file filename: "SimpleCV", path: nil output_path = File.join(path || Dir.pwd, "#{filename.chomp('.pdf')}.pdf") Layout.new(config: @config).render_file(output_path) output_path end
Private Instance Methods
build_struct_tree(data)
click to toggle source
Struct tree
Since i prefere to use dot notation to navigate through medium size hashes, parse hash into open structs
# File lib/simple_cv/basic.rb, line 49 def build_struct_tree data data.to_hashugar end
parse_config_file(config_path)
click to toggle source
Parse config
Currently yml and json files are supported. Will parse file content to hash.
# File lib/simple_cv/basic.rb, line 32 def parse_config_file config_path File.open(config_path, "r") do |file| case File.extname(file).delete(".") when "json" then JSON.parse(file.read) when "yml" then YAML.load_file(file) else file.close raise LoadError, "Type of file is not supported." end end end