Sha256: 49fb99d31ab49699c16d304b85ef255fe24d46aacf9820ae0f7c5d17dc53ca2c

Contents?: true

Size: 739 Bytes

Versions: 2

Compression:

Stored size: 739 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
      { "owner" => @owner.to_hash, "group" => @group.to_hash, "other" => @other.to_hash }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ykutils-0.1.10 lib/ykutils/filepermision.rb
ykutils-0.1.8 lib/ykutils/filepermision.rb