Class: Firefox::Profile
- Inherits:
-
Object
- Object
- Firefox::Profile
- Defined in:
- lib/firefox/profile.rb
Instance Attribute Summary collapse
-
#logins ⇒ Object
readonly
Returns the value of attribute logins.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(name, path) ⇒ Profile
constructor
A new instance of Profile.
- #inspect ⇒ Object
- #load_logins(decrypt: false) ⇒ Object
- #to_s ⇒ Object
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
#logins ⇒ Object (readonly)
Returns the value of attribute logins.
22 23 24 |
# File 'lib/firefox/profile.rb', line 22 def logins @logins end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
22 23 24 |
# File 'lib/firefox/profile.rb', line 22 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
22 23 24 |
# File 'lib/firefox/profile.rb', line 22 def path @path end |
Instance Method Details
#inspect ⇒ Object
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_data| login = Login.from_json(login_data) login.decrypt() if decrypt logins << login end @logins = logins end |
#to_s ⇒ Object
30 31 32 |
# File 'lib/firefox/profile.rb', line 30 def to_s() "#<Firefox::Profile #{@name}>" end |