Sha256: e6501fbace612d162dc69e7d54f4214818444dc5e03628814d1d0c30128f20d7

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

# -*- coding: utf-8 -*-
module DirCat

  class EntrySer < OpenStruct
  end

  #
  # Entry
  #
  class Entry

    attr_reader :md5
    attr_reader :name
    attr_reader :path
    attr_reader :size
    attr_reader :mtime

    def from_filename( filename )
      @name = File.basename(filename)
      @path = File.dirname(filename)
      stat = File.stat(filename)
      @size = stat.size
      @mtime = stat.mtime
      # self.md5 = Digest::MD5.hexdigest(File.read( f ))
      @md5 = MD5.file( filename ).hexdigest
      self
    end

    def from_ser( entry_ser )
      @md5   = entry_ser.md5
      @name  = entry_ser.name
      @path  = entry_ser.path
      @size  = entry_ser.size
      @mtime = entry_ser.mtime
      self
    end

    def to_ser
      entry_ser = EntrySer.new
      entry_ser.md5   = @md5
      entry_ser.name  = @name
      entry_ser.path  = @path
      entry_ser.size  = @size
      entry_ser.mtime = @mtime
      entry_ser
    end

    def to_s
      @md5 + "  " + @name + "\t " + @path + "\n"
    end

  end

  class DirCatSer < OpenStruct
  end


  class DirCatException < RuntimeError
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dircat-0.1.12 lib/dircat/entry.rb
dircat-0.1.11 lib/dircat/entry.rb
dircat-0.1.10 lib/dircat/entry.rb
dircat-0.1.9 lib/dircat/entry.rb
dircat-0.1.8 lib/dircat/entry.rb
dircat-0.1.7 lib/dircat/entry.rb
dircat-0.1.6 lib/dircat/entry.rb