Sha256: ec830c63cdb8db071d44193f622e42bb624c3703904c58e7524b0afdafdd4af0

Contents?: true

Size: 453 Bytes

Versions: 1

Compression:

Stored size: 453 Bytes

Contents

module Wasserstand
  module Finders
    def [](name)
      return nil if name.to_s.empty?
      results = all.select{|named| UnicodeUtils.upcase(name) == named.name}

      case results.size
      when 0
        nil # loookup returns nil if not found. This is a lookup, not find_all.
      when 1
        results.first
      else
        raise AmbigousNameError "Name '#{name}' is not unique. Found #{results.size} results."
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wasserstand-0.0.10 lib/wasserstand/finders.rb