Reading YAML with Ruby, unexpected return type
<p>I have a YAML file that has a couple keys with multiple values and a couple with one value:</p>

<pre><code>inbox:
  paul: 'PHILADELPHIA-RO-ADMIN'
  tanny: 'PA-C-INDIANA-ADMIN'
  mary:
          - 'MD-C-LAUREL-ADMIN'
          - 'MD-E-BALTIMORE-ADMIN'
          - 'MD-R1-CAMBRIDGE-ADMIN'
          - 'MD-R2-BELAIR-ADMIN'
          - 'MD-R4-LAUREL-ADMIN'
          - 'MD-R5-HAGERSTWN-ADMIN'
  mike:
          - 'VA-E-Richmond-Admin'
          - 'VA-Richmond-Admin'
          - 'VA-Manassas-Admin'
          - 'VA-Norfolk-Admin'
          - 'VA-Roanoke-Admin'
          - 'VA-Verona-Admin'
</code></pre>

<p>What I'm attempting to do is if the key has more than one value output the key has more than one value, however if the key has only one value, only output that value. I'm trying to use the <code>Array.count</code> function to do this, I've come across an issue where if the Array has only one value it counts amount of characters inside of the key, for example:</p>

<pre><code>require 'yaml'

POC = YAML.load_file('test.yml')

def get_poc(name)

  data = POC['inbox'][name.downcase]
  puts data.count
  if data.count == 1
    POC['inbox'][name]
  else
    puts "Multiple inboxes found for #{name.capitalize.chomp}"
    data.each.with_index(1) do |str, i|
      puts "#{i}. #{str}"
    end
    puts 'One of the above inboxes is the correct inbox for this ticket.'
  end
end
</code></pre>

<p>When this is run in IRB:</p>

<pre><code>irb(main):020:0&gt; get_poc('mary')
6
Multiple inboxes found for Mary
1. MD-C-LAUREL-ADMIN
2. MD-E-BALTIMORE-ADMIN
3. MD-R1-CAMBRIDGE-ADMIN
4. MD-R2-BELAIR-ADMIN
5. MD-R4-LAUREL-ADMIN
6. MD-R5-HAGERSTWN-ADMIN
One of the above inboxes is the correct inbox for this ticket.
=&gt; nil
irb(main):021:0&gt; get_poc('paul')
21
ArgumentError: wrong number of arguments (given 0, expected 1+)
        from (irb):10:in `count'
        from (irb):10:in `get_poc'
        from (irb):21
        from C:/Ruby23/bin/irb.cmd:19:in `&lt;main&gt;'
irb(main):022:0&gt;
</code></pre>

<p>It seems that it works for multiple values, however when there's only one value given it seems to actually count the full length of the value by characters. </p>

<p>I've also tried using the <code>Array.length</code> method:</p>

<pre><code>require 'yaml'

    POC = YAML.load_file('test.yml')

    def get_poc(name)

      data = POC['inbox'][name.downcase]
      puts data.length
      if data.length == 1
        POC['inbox'][name]
      else
        puts "Multiple inboxes found for #{name.capitalize.chomp}"
        data.each.with_index(1) do |str, i|
          puts "#{i}. #{str}"
        end
        puts 'One of the above inboxes is the correct inbox for this ticket.'
      end
    end
</code></pre>

<p>Same issue different error:</p>

<pre><code>irb(main):040:0&gt; get_poc('mary')
6
Multiple inboxes found for Mary
1. MD-C-LAUREL-ADMIN
2. MD-E-BALTIMORE-ADMIN
3. MD-R1-CAMBRIDGE-ADMIN
4. MD-R2-BELAIR-ADMIN
5. MD-R4-LAUREL-ADMIN
6. MD-R5-HAGERSTWN-ADMIN
One of the above inboxes is the correct inbox for this ticket.
=&gt; nil
irb(main):041:0&gt; get_poc('paul')
21
Multiple inboxes found for Paul
NoMethodError: undefined method `each' for "PHILADELPHIA-RO-ADMIN":String
        from (irb):34:in `get_poc'
        from (irb):41
        from C:/Ruby23/bin/irb.cmd:19:in `&lt;main&gt;'
irb(main):042:0&gt;
</code></pre>

<p>How can I get the method to only count the value as one element?</p>