From Fedora Project Wiki

< FWN

 
Line 114: Line 114:


====Fedora 15 Beta is hereby declared GOLD!====   
====Fedora 15 Beta is hereby declared GOLD!====   
Robyn Bergeron<ref>Robyn Bergeron rbergero at redhat.com</ref> on Wed Apr 13 21:41:00 UTC 2011 announced<ref>http://lists.fedoraproject.org/pipermail/devel-announce/2011-April/000777.html</ref>,
[[User:Rbergero|Robyn Bergeron]] on Wed Apr 13 21:41:00 UTC 2011 announced<ref>http://lists.fedoraproject.org/pipermail/devel-announce/2011-April/000777.html</ref>,


"At the Fedora 15 Beta Go/No-Go meeting today, the F15 Beta was declared  
"At the Fedora 15 Beta Go/No-Go meeting today, the F15 Beta was declared  

Latest revision as of 15:06, 16 April 2011

Fedora Weekly News Issue 271

Welcome to Fedora Weekly News Issue 271[1] for the week ending April 13, 2011. What follows are some highlights from this issue.

In Announcements, details on the next FUDCon EMEA, to be held in Milan, Italy, results of voting for the next Fedora 16 release name, and details on Fedora 15 reaching beta gold status. Fedora In the News this week reports on a whopping eleven articles in the trade press and blogosphere on Fedora 16, Gnome 3, LibreOffice and use of Linux at Yahoo. QA team news this week provides details on the latest Test Day on ABRT and this week's Test Day on virtualization, Fedora 15 beta readiness and further work on systemd and Gnome shell documentation. In Security Advisories this week, we're brought current with the latest security-related packages for Fedora 13, 14 and 15. Finally, this week we bring the third installment on Ruby in Fedora LATAM, for our Spanish-language readers. Enjoy!

An audio version of some issues of FWN - FAWN - are available! You can listen to existing issues[2] on the Internet Archive. If anyone is interested in helping spread the load of FAWN production, please contact us!

If you are interested in contributing to Fedora Weekly News, please see our 'join' page[3]. We welcome reader feedback: news@lists.fedoraproject.org

FWN Editorial Team: Pascal Calarco, Adam Williamson

Announcements

In this section, we cover announcements from the Fedora Project, including general announcements[1], development announcements[2] and Events[3].

Contributing Writer: Rashadul Islam

Fedora Announcement News

The announcement list is always exclusive for the Fedora Community. Please, visit the past announcements at[1]

FUDCon EMEA 2011 will be held in Milan, Italy

Jared K. Smith on Mon Apr 11 21:50:49 UTC 2011 announced[1],

"I am pleased to announce that the FUDCon conference in the EMEA region in 2011 will be in Milan, Italy. We had four excellent bids for the EMEA FUDCon this year (Milan, Budapest, Dublin, and Zurich) and all four proposals were well done. The Milan bid has several potential dates, so I will be working together with the Milan bid team and FAmSCo and our community of European ambassadors to choose a date that works well for all involved."

Results of Fedora 16 Release Name Voting

Jared K. Smith on Tue Apr 12 13:29:14 UTC 2011 announced[1],

"The voting has concluded for the Fedora 16 release name, and the results are in! Thank you to the Fedora community members who made name suggestions and participated in the voting.

The Fedora 16 release name is: Verne

Voting period: Tuesday 2011-04-05 00:00:00 to Monday 2011-04-11 23:59:59 Number of valid ballots cast: 421

Using the range voting method, each candidate could attain a maximum of (421*9) = 3789 votes.

Results:

Votes :: Name

  • 2204 :: Verne
  • 1662 :: Beefy Miracle
  • 1522 :: Omoto
  • 1241 :: Nepia
  • 1207 :: Bonnet
  • 1157 :: Barona
  • 908 :: Llullaillaco
  • 845 :: Legation
  • 607 :: Mt. Orne"

Fedora Development News

The Development Announcement[1] list is intended to be a LOW TRAFFIC announce-only list for Fedora development.

Acceptable Types of Announcements

  • Policy or process changes that affect developers.
  • Infrastructure changes that affect developers.
  • Tools changes that affect developers.
  • Schedule changes
  • Freeze reminders

Unacceptable Types of Announcements

  • Periodic automated reports (violates the INFREQUENT rule)
  • Discussion
  • Anything else not mentioned above

Fedora 15 Beta Go/No-Go Meeting Wednesday, April 13, 2011 @ 21:00 UTC

Robyn Bergeron on Mon Apr 11 20:40:14 UTC 2011 announced[1],

"Join us on irc.freenode.net #fedora-meeting for this important meeting.

Wednesday, April 13, 2011 @ 21:00 UTC (17:00 EDT/14:00 PDT)

"Before each public release Development, QA, and Release Engineering meet to determine if the release criteria are met for a particular release. This meeting is called the: Go/No-Go Meeting."

"Verifying that the Release criteria are met is the responsibility of the QA Team."

For more details about this meeting see: [2]

In the meantime keep an eye on the Fedora 15 Beta Blocker list and help us get the testing matrix completed by testing.

[3] (One approved blocker left, currently in VERIFIED - woohoo!) [4]"

Fedora 15 Beta is hereby declared GOLD!

Robyn Bergeron on Wed Apr 13 21:41:00 UTC 2011 announced[1],

"At the Fedora 15 Beta Go/No-Go meeting today, the F15 Beta was declared GOLD and ready for release on April 19, 2011.

Thanks to everyone, as always, for their hard work and participation in getting this out the door. :)

Meeting minutes are below. -Robyn


  1. fedora-meeting: Fedora 15 Beta Go/No-Go Meeting


Meeting started by rbergeron at 21:00:30 UTC. The full logs are available at http://meetbot.fedoraproject.org/fedora-meeting/2011-04-13/fedora_15_beta_gono-go_meeting.2011-04-13-21.00.log.html .

Meeting summary
  • Roll Call! (rbergeron, 21:00:54)
  • Need representatoin from QA, Rel-eng, fesco. (rbergeron, 21:01:54)
  • Why we're here: (rbergeron, 21:05:06)
  • LINK: [2]

(rbergeron, 21:05:17)

  • In a nutshell: we are gathered today to determine if release criteria have been met and if the release can be considered GOLD.

(rbergeron, 21:05:56)

  • review of release criteria and so forth (rbergeron, 21:06:19)
  • AGREED: - remaining blocker, bz 657618, is in verified, only hitting one person, fix is in RC2 already, should not block the release.

(rbergeron, 21:11:16)

  • LINK:

[3] (adamw, 21:11:45)

  • LINK:

[4] (adamw, 21:11:50)

  • [5] (adamw, 21:16:45)
  • AGREED: No unresolved blocker bugs and all release criteria being met, Fedora 15 Beta is hereby declared GOLD. (rbergeron, 21:30:52)
  • Open discussion (rbergeron, 21:31:01)

Meeting ended at 21:33:49 UTC.

Action Items, by person
  • **UNASSIGNED**
  • (none)
People Present (lines said)
  • rbergeron (66)
  • adamw (59)
  • jlaska (21)
  • dgilmore (14)
  • nirik (8)
  • nb (6)
  • zodbot (5)
  • jsmith (5)
  • fenrus02 (3)
  • cwickert (3)
  • red_alert (1)

Generated by MeetBot_ 0.1.4"

Fedora Events

The purpose of event is to build a global Fedora events calendar, and to identify responsible Ambassadors for each event. The event page is laid out by quarter and by region. Please maintain the layout, as it is crucial for budget planning. Events can be added to this page whether or not they have an Ambassador owner. Events without an owner are not eligible for funding, but being listed allows any Ambassador to take ownership of the event and make it eligible for funding. In plain words, Fedora events are the exclusive and source of marketing, learning and meeting all the fellow community people around you. So, please mark your agenda with the following events to consider attending or volunteering near you!

Upcoming Events (March - May 2011)

  • North America (NA)[1]
  • Central & South America (LATAM): [2]
  • Europe, Middle East, and Africa (EMEA)[3]
  • India, Asia, Australia (India/APJ)[4]

Past Events

Archive of Past Fedora Events[1]

Additional information

  • Reimbursements -- reimbursement guidelines.
  • Budget -- budget for the current quarter (as distributed by FAMSCo).
  • Sponsorship -- how decisions are made to subsidize travel by community members.
  • Organization -- event organization, budget information, and regional responsibility.
  • Event reports -- guidelines and suggestions.
  • LinuxEvents -- a collection of calendars of Linux events.

Fedora In the News

In this section, we cover news from the trade press and elsewhere that is re-posted to the Fedora Marketing list[1].

http://fedoraproject.org/wiki/Marketing

Contributing Writer: Pascal Calarco

7.5 Reasons to Look Forward to Fedora 15 (linux.com)

Rahul Sundaram forwarded[1] a posting on anticipated features in Fedora 15:

"One of the reasons I watch Fedora closely is that it's a precursor for enterprise Linux. Not just Red Hat Enterprise Linux (RHEL), though that's certainly true. But advancements in Fedora usually make their way into other major distributions, and Fedora is often the first distro to ship cutting (sometimes bleeding) edge software. That's not to say that the other community distros never do this, but Fedora makes a habit of pushing the envelope.

Fedora 15 is no exception — it has quite a few major new features, as well as a few enhancements that will likely influence the entire Linux landscape in the near future"

The full article is available[2].

Fedora 16 will not be a Beefy Miracle (Internetnews.com)

Rahul Sundaram forwarded[1] a report on the results of the Fedora 16 naming:

"I personally had thought that, Beefy Miracle would win, but that name only ended up with 1,662 votes. Beefy Miracle had been making a name for itself with an active Twitter feed that I have enjoyed following. There is also a project page supporting the campaign for Beefy Miracle. I've never seen so much effort and marketing going behind a potential name. It's a real shame that it didn't win."

The full article is available[2].

Fedora 16 Will Be Verne, Not A Beefy Miracle (phoronix.com)

Rahul Sundaram forwarded[1] another posting about the naming contest results for Fedora 16:

"The Fedora 16 name voting has ended. One of the leading proposals for the Fedora 16 codename was to call it a Beefy Miracle, but that will not happen. The Fedora 15 successor will be called Verne.

There was quite a campaign by Beefy Miracle proponents to the point that there was even a BeefyMiracle.org web-site all campaigning for this Fedora name."

The full article is available[2].

No Beefy Miracle for Fedora (Network World)

Rahul Sundaram forwarded[1] another despondent writer over the loss of 'Beefy Miracle':

"In a surprise upset, the Fedora Project has chosen "Verne" for Fedora 16's release name, beating out Beefy Miracle — despite strong support from former Fedora Project Leaders Paul Frields and Max Spevack.

Despite Spevack's promise to organize a weiner roast at Southeast LinuxFest 2011 and wear a hotdog hat, the vote came in with Verne ahead of Beefy Miracle by 542 votes. (Fedora uses range voting, rather than a simple majority voting system for release names.)"

The full post is available[2].

GNOME 3 set free (DesktopLinux.com)

Rahul Sundaram forwarded[1] an article on Gnome 3 in upcoming distros, including Fedora 15:

"GNOME 3.0 is a fairly radical departure from previous GNOME versions, offering a stripped-down GNOME Shell interface that enables Linux users to "focus on tasks while minimizing distractions such as notifications, extra workspaces, and background windows," says the GNOME project.

Linux distros that have already placed GNOME 3.0 front and center include Fedora Linux 15, now available in an alpha version, while many more will follow suit in the months to come."

The full post is available[2].

First Firefox 6 build next week, Firefox 7 by May, and aurora channel introduced

Rahul Sundaram forwarded[1] an article detailing upcoming Mozilla Firefox development:

"Mozilla's Engineering Project Manager, Christian Legnitto, has detailed the release schedule for Firefox 5, 6 and 7. If all goes to plan, Firefox 6.0a1 will be released next week, April 12, and Firefox 7.0a1 in the middle of May. The final build of Firefox 5 should be released on June 21, exactly three months after the release of Firefox 4."

The full post is available[2].

Interview: Charles H. Schulz on LibreOffice and The Document Foundation

Rahul Sundaram forwarded[1] an interview with Charles H. Schulz:

"The tipping point is an interesting question: you’re the first one to ask it! Given that the Document Foundation is made of many people with a diverse background and history with OpenOffice.org, I would say that there were in fact several different tipping points depending of the persons. For me, the tipping point was reached when I stopped feeling that I had any sort of value in the eyes of the new steward. I felt I was somewhere an expense on a sheet, and given that I was contributing to that project for free, it made me think really fast about all this. I think there was hope for some time that Oracle would be a good steward."

The full interview is available[2].

New GNOME Cuts the Clutter (PC World)

Rahul Sundaram forwarded[1] another review of GNOME 3:

"Five years in the making, the newly released version 3 of the GNOME Linux desktop interface has been radically redesigned.

The development team endeavored to develop a simpler interface for the shell, noted Jon McCann, one of GNOME Shell's designers, in a Thursday announcement.

Fedora will include GNOME 3 as the default interface for its upcoming Fedora 15 release, due in May. GNOME 3.0 is also available in downloadable trial versions that can be loaded onto a thumb drive."

The full article is available[2].

Yahoo: The Linux Company (ZDNet)

Rahul Sundaram forwarded[1] an interesting article on Yahoo and its use of Linux:

"Today, at the Linux Foundation Collaboration Summit, Sven Dummer, Director of Linux engineering at Yahoo!, explained that 75% of Yahoo’s Web sites and services run on Linux. The rest? It runs on FreeBSD.

"So what does Yahoo use? Well, Dummer explained, “Yahoo has its own Linux distribution, YLinux, targeted for out specific needs. It’s based on Red Hat’s Red Hat Enterprise Linux (RHEL). Yes, that’s right Yahoo is another Red Hat customer helping Red Hat become a billion dollar company.

Yahoo does, however, support its own supporting software package system. That’s a relic, Dummer said, of its FreeBSD ancestry. This system is used to package up new software and patches for both RHEL and FreeBSD. At the same time, Yahoo does use the RPM Package Manager (RPM, yes it’s a recursive acronym) for a lot of its internal software deployment."

The full article is available[2].

Focusing on what's important, not sensational (ITWorld.com)

Rahul Sundaram forwarded[1] an opinion piece on GNOME 3 and negative press:

"What really cranks my brain is the clumsy and obvious attempts by some of us in the media to somehow use GNOME 3 as a way to re-kindle the desktop wars. It's GNOME vs. KDE all over again, they shout in text, when really, it's no such thing. Anyone who tell you otherwise is just trying to drum up headlines for their publication. KDE and GNOME are different, thank you very much, but they are not out to kill each other off."

The full article is available[2].

Quick look at Fedora-inspired Fusion Linux 14 - Mini Review

Rahul Sundaram forwarded[1] a short blog review of Fedora 14:

"Round-up: Fusion Linux is slightly buggy, but a good choice for home users who want everything out of the box and do not want the hassle of adding extra repositories to get codecs and then install them. If Windows gaming on Linux is your thing, this distribution could work for you. If you're not fussy about disk space and the mix of libraries thrown your way in Fusion, or you are already using Mint and are looking to move or just try out a Fedora base, this could also be interesting. And for advanced users, don't forget, you can customize the kickstart file from the start as it is available on their website. And it's an installable live medium and runs well from DVD too."

The full posting is available[2].

QualityAssurance

In this section, we cover the activities of the QA team[1]. For more information on the work of the QA team and how you can get involved, see the Joining page[2].

Contributing Writer: Adam Williamson

Test Days

Thursday 2011-03-31 was ABRT Test Day[1]. As well as checking that ABRT (Fedora's automated crash report tool) is working as expected for Fedora 15, we tested out a big new feature, the retrace server[2]. This allows you to submit crash reports to a remote server which will generate the backtrace - avoiding the need for you to download and install often large debuginfo packages in order to submit reports. Michal Nowak posted a recap[3] of the event, noting that there had been eight testers and seventeen bugs filed overall.

This Thursday, 2011-04-14, will be virtualization Test Day[4], where our awesome virtualization team, starring Justin Forbes[5], will be our guides as we test the various virtualization features of Fedora 15, including shiny SPICE support in virt-manager[6]. Virtualization is a key component of any distribution nowadays, and the virtualization team always put on a smoothly run event, so please come along and help us test!

Fedora 15 Beta preparation

Preparation for the Fedora 15 Beta release moved into high gear over the last couple of weeks, with two more blocker review meetings[1] [2] and the TC1[3], RC1[4] and RC2[5] releases. Many testers made valuable contributions to the desktop and installation validation testing processes for each of these releases, and we were able to achieve comprehensive test coverage, and identify several blocker issues for the development team to fix. The group was able to catch SELinux issues caused by the introduction of the /run directory[6] very early and ensure the change did not land in the 'stable' Fedora 15 repository until this was resolved, and did not affect the Beta release.

Systemd and GNOME Shell documentation

Rahul Sundaram posted some documentation on Systemd[1] and GNOME Shell[2]. Both posts led to some lively discussion and suggested improvements.

Release criteria revisions

Adam Williamson announced his intention to push various recently discussed release criteria revisions into production[1], and later announced that he had done so[2]. In the meantime, a discussion developed on how to capture the fact that some desktops can block the release and some cannot in a clear yet future-proof way, with another proposal from Adam[3] and some well-considered reservations[4] from Jóhann Guðmundsson.

Bruno Wolff suggested criteria for image sizes[5], to ensure that images at each release point are of an appropriate size for convenient testing. Adam provided a proposed wording[6]. Dennis Gilmore pointed out that the sources DVD should probably be exempt from the criterion[7], at least until final release time.

Slow login investigation

Joachim Backes reported that he was seeing slow logins in Fedora 15[1], and Panu Matilainen confirmed the issue[2]. Panu was able to pinpoint the issue as a bug in at-spi2-core[3] and help the desktop team to produce a fix. Great work!

Security Advisories

In this section, we cover Security Advisories from fedora-package-announce from the past week.

http://lists.fedoraproject.org/pipermail/package-announce

Contributing Writer: Pascal Calarco

Fedora 15 Security Advisories

none

Fedora 14 Security Advisories

Fedora 13 Security Advisories

LATAM Fedora!

LATAM Fedora is a regular column of Spanish language contributions around open source software. It is our first expansion into incorporating foreign language content into FWN.

This week's contribution is from Guillermo Gómez, a third installment on Ruby. Enjoy!

Ruby Capítulo 3 : Métodos

Como ya hemos venido desarrollando en nuestra previas entregas, los métodos sabemos se definen por medio de la palabra clave def. Los nombres de métodos deben comenzar con una letra minúscula. Los métodos que funcionan como consultas suelen ser llamados con el sufijo "?", tal como instance_of? Los métodos peligrosos o que modifican el objeto mismo suelen también llamarse con un el sufijo "!". Por ejemplo String tiene el método chop y chop!. El primero devuelve un string modificado, el segundo modifica el objeto mismo.

El cuerpo de un método contiene expresiones Ruby normales, excepto que no se puede definir un método de instancia, clase o modulo dentro de un método, si lo intenta obtendrá un error como el siguiente:

1 SyntaxError: compile error
2 (irb):2: class definition in method body
3     from (irb):7

El valor devuelto por los métodos es el valor de la última expresión ejecutada, o el resultado explícito de una expresión return.

1 >> def resultado
2 >> "Uno" 
3 >> end
4 >> p resultado
5 "Uno" 
6 
7 >> def resultado
8 >> "Uno" 
9 >> return true
10 >> end
11 => nil
12 >> p resultado
13 true

Parámetros

Ya que sabe definir un método con su nombre, ahora seguramente se encontrará con la necesidad de invocar el método pasando parámetros.

1 def miMetodo(arg1, arg2, arg3)
2   # su codigo
3 end
4 
5 def miOtroMetodo
6   # sin argumentos
7   # su codigo
8 end

Ruby le permite definir valores por omisión a los argumentos de lo métodos que son obviados durante la invocación.

1 def trampa(arg1="boba", arg2="tnt", arg3="30s")
2   "#{arg1}, #{arg2}, #{arg3}" 
3 end
1 ?> trampa
2 => "boba, tnt, 30s" 
3 >> trampa("lisa")
4 => "lisa, tnt, 30s" 
5 >> trampa("lisa","h2o")
6 => "lisa, h2o, 30s" 
7 >> trampa("lisa","h2o", "45h")
8 => "lisa, h2o, 45h" 

Si desea pasar una cantidad variable de argumentos, o desea capturar múltiples argumentos en un único parámetro, el colocar un asterisco (*) antes del nombre del último argumento hace justo eso.

1 def varargs(arg1, *resto)
2   "Recibi #{arg1} y #{resto.join(', ')}" 
3 end
1 >> varargs("uno")
2 => "Recibi uno + " 
3 >> varargs("uno","dos")
4 => "Recibi uno + dos" 
5 >> varargs("uno","dos","tres")
6 => "Recibi uno + dos, tres" 
7 >> varargs("uno","dos","tres", "cuatro")
8 => "Recibi uno + dos, tres, cuatro" 

El resto de argumentos se apilan en un Array y se pone a disposición del método bajo el nombre especificado.

Métodos con y sin bloques asociados

Una técnica poderosa con Ruby es la posibilidad de asociar bloques de código a los métodos, veamos un ejemplo simple para ilustrar la técnica.

1 >> def con_y_sin_bloque(p1)
2 >>   if block_given?
3 >>     yield(p1)
4 >>   else
5 ?>     p1
6 >>   end
7 >> end
8 => nil
9 >> con_y_sin_bloque(10) { |p1| (1..5).each { |m| p m + p1 } }
10 11
11 12
12 13
13 14
14 15
15 => 1..5
16 >> con_y_sin_bloque(10)
17 => 10

Para determinar la presencia del bloque hemos usado el método block_given? para condicionar el procesamiento en la ejecución del método. Luego yield permite ejecutar dicho bloque de código ruby con el argumento que deseemos, en este caso p1.

Si en la definición de método, el último parámetro es precedido por un ampersand "&", cualquier bloque asociado a la llamada es convertido a un objeto Proc y dicho objeto es asignado a dicho parámetro, veamos un ejemplo para visualizar su uso.

1 class CalculadoraDeVentas
2   def initialize(nombre, &bloque)
3     @nombre, @bloque = nombre, bloque
4   end
5 
6   def precio_de_venta(costo)
7     @bloque.call(costo)
8   end
9 end
1 >> cpd = CalculadoraDeVentas.new("Distribuidor1") { |costo| p "Precio de venta #{(1.5*costo).to_s} BsF." }
2 => #<CalculadoraDeVentas:0xb735ccc8 @nombre="Distribuidor1", @bloque=#<Proc:0xb735cd18@(irb):75>
3 >> cpm = CalculadoraDeVentas.new("Minorista1") { |costo| p "Precio de venta #{(1.8*costo).to_s} BsF." }
4 => #<CalculadoraDeVentas:0xb7347008 @nombre="Minorista1", @bloque=#<Proc:0xb7347058@(irb):77>
5 
6 >> cpd.precio_de_venta(100)
7 "Precio de venta 150.0 BsF." 
8 => nil
9 >> cpm.precio_de_venta(100)
10 "Precio de venta 180.0 BsF." 
11 => nil

En el ejemplo hemos introducido el uso del método call de Proc para invocar la ejecución correspondiente y con los argumentos necesarios. Tendremos más que decir acerca de Proc en futuras ediciones.

Por supuesto que esta funcionalidad puede implementarse de otras maneras, muchas otras maneras, el ejemplo lo que demuestra sutilmente es que también es posible reusar bloques de código por medio del uso de los bloques asociados a las llamadas de los métodos, es decir, puede por ejemplo compartir un bloque de código con más de una definición de método en su aplicación de hecho reduciendo y reusando el código por medio de funcionalidad común no representaba en clases o módulos. Esto igualmente puede hacerse en tiempo de ejecución, es decir, código que genera código y que lo pasa otro código para que lo ejecute. Si está confundido es porque está comenzando a experimentar el fuerte componente de dinamismo que tiene Ruby, no se asuste y abrace el poder que de esto se deriva.

Invocando los métodos

Usted puede invocar o "llamar" un método especificando un "receptor" (objeto), el nombre del método, y opcionalmente algunos parámetros y un bloque asociado. Para el caso de los métodos de clase y módulo, el receptor sería el nombre de clase o módulo.

1 File.size("archivo_grande.mpeg") 2 Math.sin(Math::PI/3)

Si se omite el receptor, se usa self, el objeto actual:

1 >> self.class
2 => Object
3 >> self.hash
4 => -608576338
5 >> hash
6 => -608576338
7 >> self.object_id
8 => -608576338
9 >> object_id
10 => -608576338

Note que he evitado intencionalmente llamar a class omitiendo el receptor, y ello es porque provoca un error, class es ambiguo, es una palabra clave (keyword) y Ruby cree que usted está tratando de definir una clase, no intenta self.class. En estos casos, use self.class, en general es mejor explicitar el receptor, es más legible y potencialmente evitará estas ambigüedades difíciles de depurar.

También observe con cuidado que no es igual Object.hash a self.hash ya que self es una instancia de Object en el ejemplo y Object.hash es un método de clase, referencian a hash diferentes, uno a la instancia (self), y el otro a la clase Object.

1 >> self.class
2 => Object
3 >> self.object_id
4 => -608576338
5 >> Object.object_id
6 => -608573798

Los paréntesis en la llamada al método para listar los argumentos son opcionales, sin embargo para evitar ambigüedades, le recomendamos fuertemente que siempre use los paréntesis, tal vez sólo en los casos más simples puede evitarse.

Expandiendo arreglos en las llamadas

De forma similar a la invocación con asterisco, en reversa, al invocar un método es posible "expandir" un arreglo para que cada elemento sea tomado como elemento individual.

1   def cinco(a,b,c,d,e)
2     "Argumentos #{a} #{b} #{c} #{d} #{e}" 
3   end
1 >> cinco("un", *["dos", "tres" , "cuatro", "cinco"])
2 => "Argumentos un dos tres cuatro cinco" 
3 >> cinco(*["un", "dos", "tres" , "cuatro", "cinco"])
4 => "Argumentos un dos tres cuatro cinco" 
5 >> cinco("un", *["dos", "tres" , "cuatro", "cinco"])
6 => "Argumentos un dos tres cuatro cinco" 
7 >> cinco("un", *["dos", "tres"] , "cuatro", "cinco")     # Debe ser el último argumento
8 SyntaxError: compile error

Argumentos opcionales

Usando el mismo ejemplo de arriba, intente pasar menos de cinco argumentos:

1 >> cinco
2 ArgumentError: wrong number of arguments (0 for 5)

Los cinco argumentos son obligatorios, una forma de convertirlos en opcionales es asignarles un valor por omisión nil.

1   def cinco(a=nil,b=nil,c=nil,d=nil,e=nil)
2     "Argumentos #{a} #{b} #{c} #{d} #{e}" 
3   end
1 >> cinco
2 => "Argumentos     " 
3 >> cinco("uno")
4 => "Argumentos uno    " 

Sin embargo note que no puede especificar el tercer argumento sin especificar el segundo, debe respetar la secuencialidad en la definición de los argumentos. Veamos la siguiente versión revisada para visualizar los argumentos pasados al método.

1   def cinco(a=nil,b=nil,c=nil,d=nil,e=nil)
2     "Argumentos 1:#{a} 2:#{b} 3:#{c} 4:#{d} 5:#{e}" 
3   end

Use nil para saltar al próximo argumento en la lista cuanda haga la invocación del método.

1 >> cinco
2 => "Argumentos 1: 2: 3: 4: 5:" 
3 >> cinco("A",nil,nil,"D")
4 => "Argumentos 1:A 2: 3: 4:D 5:" 

Simulando argumentos por nombres: hash

Si bien Ruby no tiene un verdadero soporte para "keyword arguments", es decir, pasar argumentos con su nombre y valor, nada nos impide simular dicho comportamiento usando un hash. Ruby incluso tiene un pequeño atajo que nos evita la sintáxis Hash {} para evitarnos confundir con un bloque asociado. El hash debe estar especificado de último en la lista de argumentos.

1 def hash_params(params)
2   p "ID: #{params[:id]}" 
3   p "Clave: #{params[:clave]}" 
4 end
code class="ruby">
>> hash_params(:id => "XXX" , :clave => "Z A Z Z")
"ID: XXX" 
"Clave: Z A Z Z" 
=> nil
>> hash_params(:clave => "1 2 3 4", :id => "007")
"ID: 007" 
"Clave: 1 2 3 4" 
=> nil
>> hash_params({:clave => "1 2 3 4", :id => "007"})   # Sintaxis estricta con las {}
"ID: 007" 
"Clave: 1 2 3 4" 
Loading...
Fudcon-panama-2011_728x90_leaderboard_rotated
Powered by Redmine Poder_fedora Poder_ruby Haproxy Powered_by_apache