Sha256: 26e1ec21780c5c4b1d30088cda35b4331fc70382a9f20624a709ee93e5806c3d

Contents?: true

Size: 762 Bytes

Versions: 1

Compression:

Stored size: 762 Bytes

Contents

module Ykutils
  class FilePermision
    attr_reader :owner, :group, :other
    
    class PermisionEntry
      def initialize( str )
        @read = str[0].chr
        @write = str[1].chr
        @exec = str[2].chr
      end

      def to_s
        @read + @write + @exec
      end

      def to_hash
        { "read" => @read , "write" => @write , "exec" => @exec }
      end
    end

    def initialize( str )
      @owner = PermisionEntry.new( str[0..2] )
      @group = PermisionEntry.new( str[3..5] )
      @other = PermisionEntry.new( str[6..8] )
    end

    def to_s
      @owner.to_s + @group.to_s + @other.to_s
    end

    def to_hash
      h = { "owner" => @owner.to_hash , "group" => @group.to_hash , "other" => @other.to_hash }
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ykutils-0.1.0 lib/ykutils/filepermision.rb