Top Level Namespace

Defined Under Namespace

Modules: Rbpw Classes: PwData

Instance Method Summary collapse

Instance Method Details

#clip_board_copy(key) ⇒ Object



41
42
43
# File 'lib/rbpw/main.rb', line 41

def clip_board_copy(key)
  Clipboard.copy(read_from_db(key).get_password)
end

#delete_item(key) ⇒ Object



35
36
37
38
39
# File 'lib/rbpw/main.rb', line 35

def delete_item(key)
  db = Redic.new
  db.call("DEL", key)
  db.quit
end

#read_from_db(key) ⇒ Object



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

def read_from_db(key)
  db = Redic.new
  value = JSON.parse(db.call("GET", key))
  data = PwData.new
  data.key = key
  data.set_username(value["username"])
  data.set_password(value["password"])
  data
end

#save_to_db(data) ⇒ Object



20
21
22
23
24
25
# File 'lib/rbpw/main.rb', line 20

def save_to_db(data)
  db = Redic.new
  value = data.get_json_value
  db.call("SET", data.key.to_s, value) #Redic is not support HASHSET
  db.quit
end

#set_data(key, username, password) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/rbpw/main.rb', line 27

def set_data(key, username, password)
  data = PwData.new
  data.key = key
  data.set_username(username)
  data.set_password(password)
  data
end