class TrackList::TemplateParser
A helper class to read/write a config file.
Public Class Methods
new(config_path)
click to toggle source
Pass in a file path to read/write the config file.
# File lib/track_list/template_parser.rb, line 11 def initialize(config_path) @config_path = config_path end
Public Instance Methods
config_exists?()
click to toggle source
Check if the config file already exists.
# File lib/track_list/template_parser.rb, line 23 def config_exists? if (File.exist?(File.expand_path(@config_path))) return true else return false end end
create_default_config()
click to toggle source
Create a default config file with some basic settings.
# File lib/track_list/template_parser.rb, line 33 def create_default_config config = { "output" => "%TRACK%. %TITLE% (%LENGTH%)" } out_file = File.new(File.expand_path(@config_path), 'w') out_file.puts(config.to_yaml) out_file.close end
load()
click to toggle source
Return the config file in a Ruby-readable format.
# File lib/track_list/template_parser.rb, line 17 def load return YAML.load(File.open(File.expand_path(@config_path))) end