On 6 April 2015 at 19:57, dheyfesson pinheiro <dheyfesson@gmail.com> wrote:
> Good afternoon, I'm starting in ruby,
> I am grieving for a parser to a file.
>
> file_example File.open = "foo.txt", "r"
> file_example.each do | line |
> puts line
> end
>
> here I can print all lines of the file.
>
> but as I can get only specific lines and use them in a function?
>
> ok. I I separate them with regex. but not know how to use these lines that
> separated within a function.
If I understand correctly perhaps you need something like
useful_lines = []
file_example File.open = "foo.txt", "r"
file_example.each do | line |
if some_test_to_indicate_whether_this_is_a_useful_line( line )
useful_lines << line
end
end
Colin
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsR4P%3DEWwwCLv%3DivMLyMAyATsZa0-X4eBrOESi0_8vgXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment