Class: FirefoxJson::Profiles
- Inherits:
-
Object
- Object
- FirefoxJson::Profiles
- Defined in:
- lib/firefox-json/profiles.rb
Overview
Access to the profiles.ini file that links to all defined profiles and their locations
Defined Under Namespace
Classes: Profile
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#initialize(path = File.join(Dir.home, '.mozilla/firefox')) ⇒ Profiles
constructor
A new instance of Profiles.
- #list ⇒ Object
Constructor Details
#initialize(path = File.join(Dir.home, '.mozilla/firefox')) ⇒ Profiles
Returns a new instance of Profiles.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/firefox-json/profiles.rb', line 27 def initialize(path = File.join(Dir.home, '.mozilla/firefox')) @ff_path = path data = IniFile.load(File.join(@ff_path, 'profiles.ini')) p_sections = data.sections.select {|section| section.start_with?('Profile')} @profile_map = p_sections.reduce({}) do |hash, section| profile = data[section] hash[profile['Name'].freeze] = profile.freeze hash end end |
Instance Method Details
#[](name) ⇒ Object
42 43 44 45 46 |
# File 'lib/firefox-json/profiles.rb', line 42 def [](name) if @profile_map.key?(name) Profile.new(@profile_map[name], @ff_path) end end |
#list ⇒ Object
38 39 40 |
# File 'lib/firefox-json/profiles.rb', line 38 def list @profile_map.keys.dup end |