class Crossfader::RCFile
Constants
- FILE_NAME
Attributes
path[R]
Public Class Methods
new()
click to toggle source
# File lib/crossfader/rcfile.rb, line 9 def initialize @path = File.join(File.expand_path('~'), FILE_NAME) @data = load_file end
Public Instance Methods
[]=(email, profile)
click to toggle source
# File lib/crossfader/rcfile.rb, line 21 def []=(email, profile) configuration['email'] = profile[:email] configuration['api_access_token'] = profile[:api_access_token] configuration['dj_name'] = profile[:dj_name] write end
api_access_token()
click to toggle source
# File lib/crossfader/rcfile.rb, line 32 def api_access_token @data['configuration']['api_access_token'] end
configuration()
click to toggle source
# File lib/crossfader/rcfile.rb, line 28 def configuration @data['configuration'] end
load_file()
click to toggle source
# File lib/crossfader/rcfile.rb, line 14 def load_file require 'yaml' YAML.load_file(@path) rescue Errno::ENOENT default_structure end
Private Instance Methods
default_structure()
click to toggle source
# File lib/crossfader/rcfile.rb, line 38 def default_structure {'configuration' => {}} end
write()
click to toggle source
# File lib/crossfader/rcfile.rb, line 42 def write require 'yaml' File.open(@path, File::RDWR | File::TRUNC | File::CREAT, 0600) do |rcfile| rcfile.write @data.to_yaml end end