Class: Firefox::Profile

Inherits:
Object
  • Object
show all
Defined in:
lib/firefox/profile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, path) ⇒ Profile

Returns a new instance of Profile.



24
25
26
27
28
# File 'lib/firefox/profile.rb', line 24

def initialize(name, path)
  @name = name
  @path = path
  @logins = nil
end

Instance Attribute Details

#loginsObject (readonly)

Returns the value of attribute logins.



22
23
24
# File 'lib/firefox/profile.rb', line 22

def logins
  @logins
end

#nameObject (readonly)

Returns the value of attribute name.



22
23
24
# File 'lib/firefox/profile.rb', line 22

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



22
23
24
# File 'lib/firefox/profile.rb', line 22

def path
  @path
end

Instance Method Details

#inspectObject



34
35
36
# File 'lib/firefox/profile.rb', line 34

def inspect()
  to_s()
end

#load_logins(decrypt: false) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/firefox/profile.rb', line 38

def load_logins(decrypt: false)
  path = @path.join('logins.json')
  data = JSON.parse(File.read(path))
  unless data.key? 'logins'
    raise InvalidProfile, "missing 'logins' entry in #{path}"
  end

  logins = []
  data['logins'].each do ||
     =  Login.from_json()
    .decrypt() if decrypt
    logins << 
  end
  @logins = logins
end

#to_sObject



30
31
32
# File 'lib/firefox/profile.rb', line 30

def to_s()
  "#<Firefox::Profile #{@name}>"
end