Faking a pass method when building an array Ruby doesn't have a pass method to 'do nothing' the way Python does - if I want a ternary statement to do something on true, but nothing on false (as in the code below). Is it bad practice in Ruby to fake it this way?

beverage_links = []

beverage_info.each do |bvg|
   self.is_menu_item?(bvg) ? beverage_links &lt;&lt; bvg["href"] : "pass"
end
What it looks like you really want is:

beverage_links = beverage_info.select{|bvg| self.is_menu_item?(bvg)}.map{|bvg|bvg["href"]}


This might be a bit confusing, so to break it down

beverage_info.select { |bvg| self.is_menu_item?( bvg ) }


This returns an array of items in beverage_info that return true* for is_menu_item?

  .map { |bvg| bvg["href"] }


This translates each of the items in the array returned in the previous into their "href" value. Finally you assign that to beverage_links.

If beverage_info is an array of beverages, I recommend you rename it to beverages. It is obvious that if you have a beverage, you have the info of that beverage.

If beverages are a custom class, give it the method is_menu_item? because nothing else will use that (unless you have, say, burgers that are also menu items. In that case, both Beverages and Burgers should extend some Food class that has the is_menu_item? method).  The way you have it now, it doesn't look like you need to be using the self keyword, but it's hard to tell without context.



* Actually, it returns all items that return ANYTHING that isn't false or nil for is_menu_item?