Class: Dir
Class Method Summary collapse
- .[](glob) ⇒ Object
- .chdir(path) ⇒ Object
- .entries(dirname) ⇒ Object
- .glob(pattern) ⇒ Object
- .home ⇒ Object
- .mkdir(path) ⇒ Object
- .pwd ⇒ Object (also: getwd)
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 |
.home ⇒ Object
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 |
.pwd ⇒ Object 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 |