Sha256: 2a81a7822089e6fbc4ac0a88de760deb5c5da8295b9b74347988184614336619

Contents?: true

Size: 873 Bytes

Versions: 1

Compression:

Stored size: 873 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)
        provider[name]
      end

      def all
        provider.all
      end

      def find_by_name(regex)
        provider.find_by_name(regex)
      end

      private

      def provider
        Wasserstand.providers[PegelOnline::WaterwayProvider]
      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

1 entries across 1 versions & 1 rubygems

Version Path
wasserstand-0.0.8 lib/wasserstand/waterway.rb