P
Panagiotis Atmatzidis
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello to the list!
I have the following code which prints the ip's from fail2ban.log and =
puts then in an array:
- --------------------------
class ReadIPs
attr_accessor :ip
def initialize(ip)
@ip =3D ip
end
=20
def ip(filename)=20
ips =3D []
File.read(filename).lines.to_a.each do |place|
sf =3D 0
while sfn =3D =
place.index(/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|=
[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4]=
[0-9]|[01]?[0-9][0-9]?)/,sf)
sf =3D sfn + 3
ips << $&
end
end
return ips
end
end
# print methods
a =3D ReadIPs.new("/Users/atma/Projects/ZoneReport/log/fail2ban.log")
puts a.ip("/Users/atma/Projects/ZoneReport/log/fail2ban.log")
- ---------------------------------
What I don't understand is why do I need to give the argument to the new =
instance of ReadIPs.new class. In my view the code should look like:
a =3D ReadIPs.new
puts a.ip("/Users/atma/Projects/ZoneReport/log/fail2ban.log")
- ----------------------------------
But this returns an error and does not run. Can someone please drop a =
few light here please
best regards & thanks in advance
Panagiotis (atmosx) Atmatzidis
email: (e-mail address removed)
URL: http://www.convalesco.org
GnuPG ID: 0xFC4E8BB4=20
gpg --keyserver x-hkp://pgp.mit.edu --recv-keys 0xFC4E8BB4
- --
The wise man said: "Never argue with an idiot. They bring you down to =
their level and beat you with experience."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.12 (Darwin)
iEYEARECAAYFAksaJSAACgkQrghUb/xOi7QoBwCffljNmCgWiDEtrmYfvyt7wjFy
8R0An0//JC5C3lH/JqJwX13PAQwTS07l
=3DmI8+
-----END PGP SIGNATURE-----
Hash: SHA1
Hello to the list!
I have the following code which prints the ip's from fail2ban.log and =
puts then in an array:
- --------------------------
class ReadIPs
attr_accessor :ip
def initialize(ip)
@ip =3D ip
end
=20
def ip(filename)=20
ips =3D []
File.read(filename).lines.to_a.each do |place|
sf =3D 0
while sfn =3D =
place.index(/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|=
[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4]=
[0-9]|[01]?[0-9][0-9]?)/,sf)
sf =3D sfn + 3
ips << $&
end
end
return ips
end
end
# print methods
a =3D ReadIPs.new("/Users/atma/Projects/ZoneReport/log/fail2ban.log")
puts a.ip("/Users/atma/Projects/ZoneReport/log/fail2ban.log")
- ---------------------------------
What I don't understand is why do I need to give the argument to the new =
instance of ReadIPs.new class. In my view the code should look like:
a =3D ReadIPs.new
puts a.ip("/Users/atma/Projects/ZoneReport/log/fail2ban.log")
- ----------------------------------
But this returns an error and does not run. Can someone please drop a =
few light here please
best regards & thanks in advance
Panagiotis (atmosx) Atmatzidis
email: (e-mail address removed)
URL: http://www.convalesco.org
GnuPG ID: 0xFC4E8BB4=20
gpg --keyserver x-hkp://pgp.mit.edu --recv-keys 0xFC4E8BB4
- --
The wise man said: "Never argue with an idiot. They bring you down to =
their level and beat you with experience."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.12 (Darwin)
iEYEARECAAYFAksaJSAACgkQrghUb/xOi7QoBwCffljNmCgWiDEtrmYfvyt7wjFy
8R0An0//JC5C3lH/JqJwX13PAQwTS07l
=3DmI8+
-----END PGP SIGNATURE-----