Sha256: fce50010fd612789cfabc36af010bc199d0c3806daa772c9b4b7bba6b415179a

Contents?: true

Size: 830 Bytes

Versions: 2

Compression:

Stored size: 830 Bytes

Contents

module Wasserstand
  # http://stackoverflow.com/questions/2030336/how-do-i-create-a-hash-in-ruby-that-compares-strings-ignoring-case
  class HashClod < Hash
    def [](key)
      key.respond_to?(:upcase) ? super(UnicodeUtils.upcase(key)) : super(key)
    end

    def []=(key, value)
      key.respond_to?(:upcase) ? super(UnicodeUtils.upcase(key), value) : super(key, value)
    end
  end

  class Waterway
    class << self
      def [](name)
        Wasserstand.waterway_provider[name]
      end

      def all
        Wasserstand.waterway_provider.all
      end

      def find_by_name(regex)
        Wasserstand.waterway_provider.find_by_name(regex)
      end
    end

    attr_reader :name, :levels

    def initialize(name)
      @name = name
      @levels = HashClod.new
    end

    def to_s
      name
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wasserstand-0.0.7 lib/wasserstand/waterway.rb
wasserstand-0.0.6 lib/wasserstand/waterway.rb