title: "Proper" idiom for handling multiple types in ruby arguments
body: <p>So I am quite new to Ruby and still learning idioms. I still have a strong static-typing mindset, so maybe one problem is that I'm over-typing. Anyway, my situation is this.</p>
  
  <p>I have an object called a Gene,with :name and :id.
  I have another object called a Genotype, which maintains an array of Gene.</p>
  
  <p>I'd like to check whether a given Genotype contains a given Gene. I'd like to able to pass Genotype.has_gene? a gene name, a gene id, or an actual Gene. In the former cases, the routine will match on name OR id, whichever is passed. If a full Gene is passed, the routine will insist on a match on both values.</p>
  
  <p>My logic is to check whether the passed value is an Integer, in which case I assume it's an id; else check if it's a String and assume it's a name; else check whether it's a Gene; else complain and bail.</p>
  
  <p>The code looks like this:</p>
  
  <pre><code>def has_gene?( gene )
        if gene.is_a? Integer
          id = gene
          name = ""
        elsif gene.is_a? String
          id = nil
          name = gene
        elsif gene.is_a? Gene
          id = gene.id
          name = gene.name
        else
          raise "Can't intepret passed data as gene information"   
        end
        name_valid = false
        id_valid = false
        @gene_specs.each do |current_gene_spec|
          current_gene = current_gene_spec.gene 
          name_valid = name.empty? || name == current_gene.name
          id_valid = id.nil? || id == current_gene.id
          break if name_valid &amp;&amp; id_valid
         end
         return name_valid &amp;&amp; id_valid
      end
  </code></pre>
  
  <p>Something feels wrong here but I can't pin it down. It seems to lack Ruby's famous conciseness :-)</p>
  
  <p>Thoughts?</p>