Sha256: 04b88a3d6244e4d80f3abfe4a6a84bcfc71ab18a07ea98ebcf79c2e229bed5ac
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
require 'ykutils/filepermision' require 'pathname' module Ykytils class DirEntryItem attr_accessor :name , :user , :group , :size , :month, :day, :time , :year, :path, :type , :parent_dir , :valid def initialize end def parse( str , parent_dir , valid = true ) ary = str.split(/\s+/) perm = ary[0] if perm[0].chr == 'd' @type = :DIRECTORY else @type = :FILE end @perm = FilePermision.new( ary[0][1..9] ) @value = ary[1] @user = ary[2] @group = ary[3] @size = ary[4] @month = ary[5] @day = ary[6] str = ary[7] if str =~ /:/ @year = Time.now.year @time = str else @year = str @time = "00:00:00" end @time = ary[7] @name = ary[8] @path = File.join( parent_dir, @name ) @parent_dir = parent_dir @valid = valid end def to_hash { "type" => @type, "perm" => @perm.to_hash, "value" => @value, "user" => @user , "group" => @group, "size" => @size, "month" => @month, "day" => @day, "year" => @year , "time" => @time, "name" => @name, "path" => @path, "parent_dir" => @parent_dir , "valid" => @valid } end def to_csv "#{@type},#{@perm.to_s},#{@value},#{@user},#{@group},#{@size},#{@year},#{@month},#{@day},#{@time},#{@name},#{@parent_dir},#{@valid}" end def directory? @type === :DIRECTORY end def file? @type === :FILE end def owner_perm @perm.owner end def group_perm @perm.group end def otherr_perm @perm.other end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ykutils-0.1.0 | lib/ykutils/lsutils.rb |