Sha256: 7e32676282fe5e79471596d19d144015768d0acc26cdf69d191271e32bb6b67b

Contents?: true

Size: 413 Bytes

Versions: 2

Compression:

Stored size: 413 Bytes

Contents

module Suricate
  class CounterWidgetResponse < WidgetResponse
    class NotAnNumberError < StandardError; end

    def initialize
      @value = nil
      super
    end

    def value(value)
      raise NotAnNumberError.new("#{value} is not a number") unless value.is_a?(Numeric)
      @value = value
    end

    def to_h
      super.tap do |hash|
        hash.merge!(value: @value)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
suricate-0.0.4 lib/suricate/widgets/responses/counter_widget_response.rb
suricate-0.0.3 lib/suricate/widgets/responses/counter_widget_response.rb