Sha256: 8bfae7f330fc550c0d8c91610bf1ad8a1ba753bc3f8e15b155b09eda944fa2aa

Contents?: true

Size: 1.28 KB

Versions: 18

Compression:

Stored size: 1.28 KB

Contents

module Frodo
  module Properties
    # Defines the Float Frodo type.
    class Float < Frodo::Property
      include Frodo::Properties::Number

      # Returns the property value, properly typecast
      # @return [Float,nil]
      def value
        if (@value.nil? || @value.empty?) && allows_nil?
          nil
        else
          @value.to_f
        end
      end

      # Sets the property value
      # @params new_value [to_f]
      def value=(new_value)
        validate(new_value.to_f)
        @value = new_value.to_f.to_s
      end

      # The Frodo type name
      def type
        'Edm.Double'
      end

      private

      def min_value
        @min ||= -(1.7 * (10**308))
      end

      def max_value
        @max ||= (1.7 * (10**308))
      end
    end

    # Defines the Double (Float) Frodo type.
    class Double < Frodo::Properties::Float; end

    # Defines the Single (Float) Frodo type.
    class Single < Frodo::Properties::Float
      # The Frodo type name
      def type
        'Edm.Single'
      end

      # Value to be used in URLs.
      # @return [String]
      def url_value
        "#{value}F"
      end

      private

      def min_value
        @min ||= -(3.4 * (10**38))
      end

      def max_value
        @max ||= (3.4 * (10**38))
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
frodo-0.12.8 lib/frodo/properties/float.rb
frodo-0.12.7 lib/frodo/properties/float.rb
frodo-0.12.6 lib/frodo/properties/float.rb
frodo-0.12.5 lib/frodo/properties/float.rb
frodo-0.12.4 lib/frodo/properties/float.rb
frodo-0.12.2 lib/frodo/properties/float.rb
frodo-0.12.1 lib/frodo/properties/float.rb
frodo-0.12.0 lib/frodo/properties/float.rb
frodo-0.11.0 lib/frodo/properties/float.rb
frodo-0.10.8 lib/frodo/properties/float.rb
frodo-0.10.7 lib/frodo/properties/float.rb
frodo-0.10.6 lib/frodo/properties/float.rb
frodo-0.10.5 lib/frodo/properties/float.rb
frodo-0.10.4 lib/frodo/properties/float.rb
frodo-0.10.3 lib/frodo/properties/float.rb
frodo-0.10.2 lib/frodo/properties/float.rb
frodo-0.10.1 lib/frodo/properties/float.rb
frodo-0.10.0 lib/frodo/properties/float.rb