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.



304
305
306
# File 'opal/stdlib/deno/file.rb', line 304

def initialize(path)
  @path = path
end

Instance Method Details

#directory?Boolean

Returns:



312
313
314
# File 'opal/stdlib/deno/file.rb', line 312

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

#executable?Boolean

Returns:



338
339
340
341
# File 'opal/stdlib/deno/file.rb', line 338

def executable?
  # accessible only over unstable API
  false
end

#file?Boolean

Returns:



308
309
310
# File 'opal/stdlib/deno/file.rb', line 308

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

#mtimeObject



316
317
318
# File 'opal/stdlib/deno/file.rb', line 316

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

#readable?Boolean

Returns:



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

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

#writable?Boolean

Returns:



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

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