Class: MacKeychain::Key

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

Overview

A Key is an existing item in Keychain, contains item reference and password

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item, password) ⇒ Key

:item => Keychain item :password => password of item



24
25
26
27
# File 'lib/mac_keychain.rb', line 24

def initialize(item, password)
  @item = item
  @password = password
end

Instance Attribute Details

#itemObject (readonly)

Returns the value of attribute item.



20
21
22
# File 'lib/mac_keychain.rb', line 20

def item
  @item
end

#passwordObject (readonly)

Returns the value of attribute password.



20
21
22
# File 'lib/mac_keychain.rb', line 20

def password
  @password
end

Class Method Details

.create(data) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/mac_keychain.rb', line 10

def self.create(data)
  password_length = data.shift
  password_data = data.shift #password data
  item = data.shift #SecKeychainItemRef
  password = if password_data
    password_data.bytestr(password_length)
  end
  self.new(item, password)
end