class Firefox::ProfileIndex
Constants
- DEFAULT_PATH
Attributes
path[R]
profiles[R]
Public Class Methods
new(path: DEFAULT_PATH)
click to toggle source
# File lib/firefox/profile_index.rb, line 21 def initialize(path: DEFAULT_PATH) @path = path @profiles = {} end
Public Instance Methods
load()
click to toggle source
# File lib/firefox/profile_index.rb, line 26 def load() sections = [] section = nil File.open(@path).each do |line| if line.match(/^\[([^\]]+)\]/) title = $1 next if title == 'General' section = {} sections << section elsif !section.nil? && line.match(/^([^=]+)\s*=\s*(.*)/) key = $1 value = $2 section[key] = value end end profiles = {} sections.each do |section| name = section['Name'] path = Pathname.new(section['Path']) is_relative = section['IsRelative'] if is_relative == '1' path = ROOT_PATH.join(path) end profile = Profile.new(name, path) profiles[name] = profile end @profiles = profiles end
profile?(name)
click to toggle source
# File lib/firefox/profile_index.rb, line 61 def profile?(name) return @profiles.key? name end