Class: File::Stat

Inherits:
Object show all
Defined in:
opal/stdlib/deno/file.rb,
opal/stdlib/nodejs/file.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Stat

Returns a new instance of Stat.



302
303
304
# File 'opal/stdlib/deno/file.rb', line 302

def initialize(path)
  @path = path
end

Instance Method Details

#directory?Boolean

Returns:



310
311
312
# File 'opal/stdlib/deno/file.rb', line 310

def directory?
  `return executeIOAction(function(){return Deno.statSync(#{@path}).isDirectory})`
end

#executable?Boolean

Returns:



336
337
338
339
# File 'opal/stdlib/deno/file.rb', line 336

def executable?
  # accessible only over unstable API
  false
end

#file?Boolean

Returns:



306
307
308
# File 'opal/stdlib/deno/file.rb', line 306

def file?
  `return executeIOAction(function(){return Deno.statSync(#{@path}).isFile})`
end

#mtimeObject



314
315
316
# File 'opal/stdlib/deno/file.rb', line 314

def mtime
  `return executeIOAction(function(){return Deno.statSync(#{@path}).mtime})`
end

#readable?Boolean

Returns:



318
319
320
321
322
323
324
325
# File 'opal/stdlib/deno/file.rb', line 318

def readable?
  %x{
    return executeIOAction(function(){
      Deno.openSync(path, {read: true}).close();
      return true;
    })
  }
end

#writable?Boolean

Returns:



327
328
329
330
331
332
333
334
# File 'opal/stdlib/deno/file.rb', line 327

def writable?
  %x{
    return executeIOAction(function(){
      Deno.openSync(path, {write: true}).close();
      return true;
    })
  }
end