How to make the path generic (RUBY)? [closed] - ruby

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
This is how I am changing the directory path to the download folder.
Dir.chdir("C:/Users/abcd/Downloads/")
But this specific to a user. Is there is any way to make it more general?

Use home method for Dir
Dir.chdir(Dir.home + '/Downloads')

The "C:/Users/abcd/Downloads/" looks like the user directory for user abcd on windows. So I think this is a windows related question.
The Dir.home on my Windows-PC is U:/, not the user-directory.
But you can make use of ENV:
Dir.chdir(File.join(ENV['USERPROFILE'], 'Downloads'))
Just to be aware of: This changes the directory for the rest of your script. There is also a block-version of Dir.chdir.

Related

How to create an executable for Ruby console application [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I'm writing a simple console app, but instead of distributing it as a script (somefile.rb), I want it as a binary file, like an executable.
Any idea?
Embedded Ruby (or better mruby) into C or C++
Simple one file with script as text.
Here is example for mruby mruby.

C:/Windows log files write to C:/mylogs.txt [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a little question for you :)
I want to write log files from C:/Windows to C:/mylogs.txt with ms-dos commands. But I don't know any ms-dos commands. How can I do this. Please help me !
If you only pretend to copy the content of Windows logs that are stored in the root folder of C:\Windows, then you could use the Copy command as follows:
Copy /B "%WinDir%\*.log" "C:\mylogs.txt"

navigate back a directory in ruby [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
How can I navigate back one or multiple directories in Ruby?
For example:
users/luigi/test/folder/file.rb
If I'm in the folder directory and want my file.rb script to load a file from within the test directory, how can I do that?
Something like:
require /../required_file.rb
You can use require_relative
require_relative "../test/file.rb"
require_relative "../requred_file.rb"

How do I create a patch file in windows? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I use windows 8 and have source codes of a software in English version.
I translated it and want to create a patch file of it. It's my first time doing it..
And.. can I use diff which I believe can be used in Linux?
winmerge can create patches is you are looking for a gui way. they have some hints for doing it scripted as well: http://manual.winmerge.org/Faq.html#d0e10357

Is there some way to write scripts for Winamp? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I like to write some scripts for Winamp. How might I do this?
You can also use gen_scripting plugin which uses JSpript or VB which might be of use to you.
And a few words to the wise: Just add the plugin to the winamp plugins directory and remember to register it with regsvr32 from the command prompt. Scripting only works with Winamp running :)

Resources