Sha256: 4ab1203536c353dc9f245a3fc89f3c6419b2b95ba85276282d4f5102d850530f

Contents?: true

Size: 617 Bytes

Versions: 1

Compression:

Stored size: 617 Bytes

Contents

# -*- encoding: utf-8 -*-
module Wasserstand
  # http://blog.steveklabnik.com/posts/2012-09-09-random-ruby-tricks--class-new
  IllegalValueError = Class.new(StandardError)

  class Trend
    def initialize(value)
      @value = {'gleich'   => :gleichbleibend,
                'steigend' => :steigend,
                'fallend'  => :fallend}[UnicodeUtils.downcase(value.to_s)]

      raise IllegalValueError, "Unknown trend #{value.inspect}" unless @value
    end

    def symbol
      {:gleichbleibend => '⬄', :steigend => '⬀', :fallend => '⬂'}[@value]
    end

    def to_s
      @value.to_s
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wasserstand-0.0.7 lib/wasserstand/trend.rb