Sha256: 41c31b4a5de4b62329c87b81fee91501d1124bdb816f0c7f2d2e97c4ebe90fe0

Contents?: true

Size: 655 Bytes

Versions: 1

Compression:

Stored size: 655 Bytes

Contents

class Danica::Formatted
  attr_reader :content, :format, :decimals

  def initialize(content, format, decimals: nil)
    @content = content
    @format = format
    @decimals = decimals
  end

  def to_s
    content.to(format, decimals: decimals)
  end

  def ==(other)
    return false unless other.class == self.class
    return other.content == content &&
           other.format == format
  end

  def repack(object)
    self.class.new(
      object,
      format
    )
  end

  private

  def method_missing(method, *args)
    value = content.public_send(method, *args)
    return value unless value.is_a?(Danica::Common)
    repack(value)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danica-2.7.2 lib/danica/formatted.rb