Class: Dir

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

Class Method Summary collapse

Class Method Details

.[](glob) ⇒ Object


12
13
14
# File 'opal/stdlib/nodejs/dir.rb', line 12

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

.chdir(path) ⇒ Object


24
25
26
# File 'opal/stdlib/nodejs/dir.rb', line 24

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

.entries(dirname) ⇒ Object


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

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


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

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


20
21
22
# File 'opal/stdlib/nodejs/dir.rb', line 20

def home
  `__os__.homedir()`
end

.mkdir(path) ⇒ Object


28
29
30
# File 'opal/stdlib/nodejs/dir.rb', line 28

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

.pwdObject Also known as: getwd


16
17
18
# File 'opal/stdlib/nodejs/dir.rb', line 16

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