Sha256: a02644cd04d125c5094440cac9c6816a6adecd9817915517810f80c4992e1ce0

Contents?: true

Size: 815 Bytes

Versions: 2

Compression:

Stored size: 815 Bytes

Contents

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
    return 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

2 entries across 2 versions & 1 rubygems

Version Path
danica-2.7.4 lib/danica/formatted.rb
danica-2.7.3 lib/danica/formatted.rb