Building a Line Counter in Ruby
Similar to the previous guide, this exercise will walk you through how to create a method that counts the number of lines in a file.
Guide Tasks
- Read Tutorial
Summary
Build a method that counts lines in a file.
Exercise File
Exercise Description
For this coding exercise, you should be able to define a method that can count the number of lines written in a file.
Example Data
expect(LineCounter.line_count('support/line_counter.txt')).to eq(42)
Real World Usage
This exercise is very simple and easy to understand. Just like the file writer method implemented in the last guide, understanding how to build an action that can count and return the number of lines in a certain file can help make a job more efficient.
Solution
Can be found on the solutions branch on github.