Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete from Hosts #3

Open
dmcdaniel12 opened this issue Mar 23, 2016 · 1 comment
Open

Delete from Hosts #3

dmcdaniel12 opened this issue Mar 23, 2016 · 1 comment

Comments

@dmcdaniel12
Copy link

Is there a way to delete from hosts file?

@aef
Copy link
Owner

aef commented Mar 23, 2016

The elements attribute of a Aef::Hosts::File is a plain and simple Array. You can just alter it in any way you can alter any Array.

For example:

hosts_file = Aef::Hosts::File.read('/etc/hosts')
hosts_file.elements.delete_at(0)
hosts_file.write

This will delete the first host in the list.

Other Array methods like #delete_if or #pop might also be of interest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants