lib/keepassx/utilities.rb in ruby-keepassx-0.2.0beta11 vs lib/keepassx/utilities.rb in ruby-keepassx-0.2.0

- old
+ new

@@ -90,11 +90,11 @@ end # Set parents for groups # - # @param [Array] list Array of groups. + # @param list [Array] Array of groups. # @return [Array] Updated array of groups. def initialize_groups list list.each_with_index do |group, index| @@ -107,13 +107,13 @@ # If group is first entry or has level equal 0, # it gets parent set to nil if previous_group.nil? or group.level.eql? 0 group.parent = nil - # If group has level greater than parent's level by one, - # it gets parent set to the first previous group with level less - # than group's level by one + # If group has level greater than parent's level by one, + # it gets parent set to the first previous group with level less + # than group's level by one elsif group.level == previous_group.level + 1 or group.level == previous_group.level group.parent = previous_group @@ -151,11 +151,11 @@ end # Retrieves last sibling index # - # @param [Keepassx::Group] parent Last sibling group. + # @param parent [Keepassx::Group] Last sibling group. # @return [Integer] index Group index. def last_sibling_index parent if groups.empty? return -1 @@ -185,19 +185,20 @@ groups, entries = opts[:groups], opts[:entries] # Remove groups and entries from options, so new group could be # initialized from incoming Hash fields = Keepassx::Group.fields - group_opts = opts.reject { |k, _| !fields.include? k } + group_opts = opts.select { |k, _| fields.include? k } group = add_group group_opts entries.each do |e| entry = e.clone add_entry entry.merge(:group => group) end unless entries.nil? # Recursively proceed each child group groups.each { |g| parse_data_array g } unless groups.nil? + end def delete_entry item item = entries.delete item