Class: SetecAstronomy::KeePass::Group

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload_io) ⇒ Group

Returns a new instance of Group.



35
36
37
38
39
40
41
42
43
# File 'lib/setec_astronomy/kee_pass/group.rb', line 35

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

  @fields = fields
end

Class Method Details

.extract_from_payload(header, payload_io) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/setec_astronomy/kee_pass/group.rb', line 26

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

Instance Method Details

#lengthObject



45
46
47
# File 'lib/setec_astronomy/kee_pass/group.rb', line 45

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

#nameObject



49
50
51
# File 'lib/setec_astronomy/kee_pass/group.rb', line 49

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