Sha256: 23dd0c340df276faf5d803de7102761507aa9927cd7a8d6635e6d20f493949c3

Contents?: true

Size: 649 Bytes

Versions: 4

Compression:

Stored size: 649 Bytes

Contents

module Danica
  class Wrapper::Number
    include BaseOperations
    include Common

    attr_accessor :value

    default_value :priority, 10
    delegate :to_f, to: :value
    default_value :is_grouped?, false

    def initialize(value)
      @value = value
    end

    def to(_, decimals: nil, **__)
      return value.to_i.to_s if value.to_i == value
      return ("%.#{decimals}f" % value).to_f.to_s if decimals
      value.to_s
    end

    def valued?
      value.present?
    end

    def signaled?
      value < 0
    end

    def ==(other)
      return false unless other.class == self.class
      value == other.value
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
danica-2.7.4 lib/danica/wrapper/number.rb
danica-2.7.3 lib/danica/wrapper/number.rb
danica-2.7.2 lib/danica/wrapper/number.rb
danica-2.7.1 lib/danica/wrapper/number.rb