Sha256: e6849c9007eab4ab3cc62eb5c6f37cec63a276a5065fadac1ed84712c37bfd99

Contents?: true

Size: 1.63 KB

Versions: 273

Compression:

Stored size: 1.63 KB

Contents

require 'etc'

module Sample

  class File
    attr_accessor :name, :ctime, :mtime, :size, :owner, :group, :permissions

    def initialize(filename)
      @name = ::File.basename(filename)
      stat = ::File.stat(filename)
      @ctime = stat.ctime
      @mtime = stat.mtime
      @size = stat.size
      @owner = Etc.getpwuid(stat.uid).name
      @group = Etc.getgrgid(stat.gid).name
      if false
        @permissions = {
          'user' => { 
            'read' => (0 != (stat.mode & 0x0100)),
            'write' => (0 != (stat.mode & 0x0080)),
            'execute' => (0 != (stat.mode & 0x0040))},
          'group' => {
            'read' => (0 != (stat.mode & 0x0020)),
            'write' => (0 != (stat.mode & 0x0010)),
            'execute' => (0 != (stat.mode & 0x0008))},
          'other' => {
            'read' => (0 != (stat.mode & 0x0004)),
            'write' => (0 != (stat.mode & 0x0002)),
            'execute' => (0 != (stat.mode & 0x0001))}
        }
      else
        @permissions = {
          'user' => [(0 != (stat.mode & 0x0100)) ? 'r' : '-',
                     (0 != (stat.mode & 0x0080)) ? 'w' : '-',
                     (0 != (stat.mode & 0x0040)) ? 'x' : '-'].join(''),
          'group' => [(0 != (stat.mode & 0x0020)) ? 'r' : '-',
                      (0 != (stat.mode & 0x0010)) ? 'w' : '-',
                      (0 != (stat.mode & 0x0008)) ? 'x' : '-'].join(''),
          'other' => [(0 != (stat.mode & 0x0004)) ? 'r' : '-',
                      (0 != (stat.mode & 0x0002)) ? 'w' : '-',
                      (0 != (stat.mode & 0x0001)) ? 'x' : '-'].join('')
        }
      end
    end

  end # File
end # Sample

Version data entries

273 entries across 273 versions & 4 rubygems

Version Path
devcycle-ruby-server-sdk-2.0.0 vendor/bundle/ruby/3.0.0/gems/oj-3.13.2/test/sample/file.rb
oj-3.14.2 test/sample/file.rb
oj-3.14.1 test/sample/file.rb
oj-3.14.0 test/sample/file.rb
oj-3.13.23 test/sample/file.rb
oj-3.13.22 test/sample/file.rb
oj-3.13.21 test/sample/file.rb
oj-3.13.20 test/sample/file.rb
oj-3.13.19 test/sample/file.rb
oj-3.13.18 test/sample/file.rb
oj-3.13.17 test/sample/file.rb
oj-3.13.16 test/sample/file.rb
oj-3.13.15 test/sample/file.rb
oj-3.13.14 test/sample/file.rb
oj-3.13.13 test/sample/file.rb
oj-3.13.12 test/sample/file.rb
oj-3.13.11 test/sample/file.rb
oj-3.13.10 test/sample/file.rb
oj-3.13.9 test/sample/file.rb
oj-3.13.8 test/sample/file.rb