Learn Ruby First
In section three, we'll explore how ruby interacts with files and the native operating system. We will also explore the world of regular expressions and see the many ways in which they can be used.
Ruby has a very rich 'File' class compared to other languages. It's easy to start working with the 'File' class, many of the method names describe their actions. Let's create a file in the Home directory called, 'file.txt':
touch file.txt irb 'file.txt') true # the file? method takes one parameter, the name of a file File.size?('file.txt') 16 # the size is returned in bytesFile.file?(
Other notable methods include:
Each of these methods asks their respective question to ruby and return a boolean.
Next, learn how to open a file with Ruby's File class.
At the end of this section there are a series of problems. Try each problem before looking at the solution. It is important to be able to take what you've learned and apply it to the problem at hand. Reading the problem and then looking at the solution won't help you improve as a developer.