Sha256: 062d360237f27c37e868e4390b6c63a0955a82e7a93ea8a83359d5b68f492249

Contents?: true

Size: 834 Bytes

Versions: 1

Compression:

Stored size: 834 Bytes

Contents

# frozen_string_literal: true

class Danica::Formatted
  attr_reader :content, :options

  def initialize(content, **options)
    @content = content
    @options = options
  end

  def to_s
    content.to(format, options)
  end

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

  def format
    options[:format]
  end

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

  def to_tex(**opts)
    to(:tex, **opts)
  end

  def to_gnu(**opts)
    to(:gnu, **opts)
  end

  def to(format, **opts)
    content.to(format, options.merge(opts))
  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.5 lib/danica/formatted.rb