Sha256: 6c4344251180b547a74f9a9a1c10b8e6dfa70c4860885f896f05a024ead0cf1c

Contents?: true

Size: 743 Bytes

Versions: 5

Compression:

Stored size: 743 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

5 entries across 5 versions & 1 rubygems

Version Path
ykutils-0.1.7 lib/ykutils/filepermision.rb
ykutils-0.1.6 lib/ykutils/filepermision.rb
ykutils-0.1.4 lib/ykutils/filepermision.rb
ykutils-0.1.3 lib/ykutils/filepermision.rb
ykutils-0.1.1 lib/ykutils/filepermision.rb