Class: Dir

Inherits:
Object show all
Defined in:
opal/stdlib/nodejs/dir.rb

Overview

backtick_javascript: true

Class Method Summary collapse

Class Method Details

.[](glob) ⇒ Object



14
15
16
# File 'opal/stdlib/nodejs/dir.rb', line 14

def [](glob)
  `__glob__.sync(#{glob})`
end

.chdir(path) ⇒ Object



26
27
28
# File 'opal/stdlib/nodejs/dir.rb', line 26

def chdir(path)
  `process.chdir(#{path})`
end

.entries(dirname) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'opal/stdlib/nodejs/dir.rb', line 34

def entries(dirname)
  %x{
    var result = [];
    var entries = __fs__.readdirSync(#{dirname});
    for (var i = 0, ii = entries.length; i < ii; i++) {
      result.push(entries[i]);
    }
    return result;
  }
end

.glob(pattern) ⇒ Object



45
46
47
48
49
50
51
52
# File 'opal/stdlib/nodejs/dir.rb', line 45

def glob(pattern)
  pattern = [pattern] unless pattern.respond_to? :each
  pattern.flat_map do |subpattern|
    subpattern = subpattern.to_path if subpattern.respond_to? :to_path
    subpattern = ::Opal.coerce_to!(subpattern, String, :to_str)
    `__glob__.sync(subpattern)`
  end
end

.homeObject



22
23
24
# File 'opal/stdlib/nodejs/dir.rb', line 22

def home
  `__os__.homedir()`
end

.mkdir(path) ⇒ Object



30
31
32
# File 'opal/stdlib/nodejs/dir.rb', line 30

def mkdir(path)
  `__fs__.mkdirSync(#{path})`
end

.pwdObject Also known as: getwd



18
19
20
# File 'opal/stdlib/nodejs/dir.rb', line 18

def pwd
  `process.cwd().split(__path__.sep).join(__path__.posix.sep)`
end