Class: SetecAstronomy::KeePass::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/setec_astronomy/kee_pass/entry.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload_io) ⇒ Entry

Returns a new instance of Entry.



44
45
46
47
48
49
50
51
52
# File 'lib/setec_astronomy/kee_pass/entry.rb', line 44

def initialize(payload_io)
  fields = []
  begin
    field = EntryField.new(payload_io)
    fields << field
  end while not field.terminator?

  @fields = fields
end

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields.



42
43
44
# File 'lib/setec_astronomy/kee_pass/entry.rb', line 42

def fields
  @fields
end

Class Method Details

.extract_from_payload(header, payload_io) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/setec_astronomy/kee_pass/entry.rb', line 33

def self.extract_from_payload(header, payload_io)
  groups = []
  header.nentries.times do
    group = Entry.new(payload_io)
    groups << group
  end
  groups
end

Instance Method Details

#lengthObject



54
55
56
# File 'lib/setec_astronomy/kee_pass/entry.rb', line 54

def length
  @fields.map(&:length).reduce(&:+)
end

#notesObject



58
59
60
# File 'lib/setec_astronomy/kee_pass/entry.rb', line 58

def notes
  @fields.detect { |field| field.name == 'notes' }.data
end

#passwordObject



62
63
64
# File 'lib/setec_astronomy/kee_pass/entry.rb', line 62

def password
  @fields.detect { |field| field.name == 'password' }.data.chomp("\000")
end

#titleObject



66
67
68
# File 'lib/setec_astronomy/kee_pass/entry.rb', line 66

def title
  @fields.detect { |field| field.name == 'title' }.data.chomp("\000")
end

#usernameObject



70
71
72
# File 'lib/setec_astronomy/kee_pass/entry.rb', line 70

def username
  @fields.detect { |field| field.name == 'username' }.data
end