[yast-devel] Re: [yast-commit] <rest-service> master : Revert "introduction to use dbus service"
* Michal Zugec <mzugec@linux.intech-solutions.com> [Aug 25. 2009 17:09]: A couple of comments:
+ ret = Scr.instance.execute(["/sbin/yast2", "lan", "list"]) + lines = ret[:stderr].split "\n" + devices = [] + lines.each do |s| + dev = Network.new
Why is the class called 'Network' and the variable 'dev' ? The class should be either called NetworkDevice or embedded inside a module (aka namespace), resulting in Network::Device
+ dev.id = s.split("\t")[0] + dev.name = s.split("\t")[1]
Its more readable (and more Ruby like) to have id and name as 'constructor' arguments: Network::Device.new id, name And these assignments are wasting cycles as you're splitting the string two times. Klaus --- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
On Tuesday 25 August 2009 17:18:38 Klaus Kaempf wrote:
* Michal Zugec <mzugec@linux.intech-solutions.com> [Aug 25. 2009 17:09]:
+ dev.id = s.split("\t")[0] + dev.name = s.split("\t")[1]
Its more readable (and more Ruby like) to have id and name as 'constructor' arguments:
Network::Device.new id, name
And these assignments are wasting cycles as you're splitting the string two times.
dev.id, dev.name = s.split You can assign to several variables at once. Also split splits on any whitespace by default. Martin Kudlvasr
Klaus --- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
-- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
participants (2)
-
Klaus Kaempf
-
Martin Kudlvasr