Sha256: 6f5c5012d526eb512b2985ba449d6ef38c5b3af07ed84fadb166f215862b5a5d

Contents?: true

Size: 617 Bytes

Versions: 1

Compression:

Stored size: 617 Bytes

Contents

module Keepasser
  class Entry
    attr_accessor :group
    attr_reader :fields

    def initialize data
      @fields = {}
      data.map do |d|
        parts = d.split ':'
        if parts[1]
          @fields[parts[0].downcase.strip] = parts[1].strip
        end
      end

      @fields['comment'] = [@fields['comment']] if @fields['comment']
      data.select { |f| f[0..5] == '      ' }.map { |c| @fields['comment'].push c.strip }
    end

    def [] key
      @fields[key]
    end

    def method_missing m, *args
      @fields[m.to_s]
    end

    def == other
      @fields == other.fields
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
keepasser-0.1.0 lib/keepasser/entry.rb