Sha256: e69948fb0407b46ad3c0be96d701fccd20b7027b1745029623869d9a43dd283d

Contents?: true

Size: 974 Bytes

Versions: 8

Compression:

Stored size: 974 Bytes

Contents

# frozen_string_literal: true

require "reverse_adoc/converters/figure"

module Stepmod
  module Utils
    module Converters
      class Figure < ReverseAdoc::Converters::Figure
        def self.pattern(state, id)
          if state[:schema_and_entity].nil?
            raise StandardError.new("[figure]: no state given, #{id}")
          end

          schema = state[:schema_and_entity].split(".").first
          "figure-#{schema}-#{id}"
        end

        def convert(node, state = {})
          # If we want to skip this node
          return "" if state[:no_notes_examples]

          # Set ID to "figure-id" in case of conflicts
          node['id'] = if node['id']
            self.class.pattern(state, node['id'])
          else
            self.class.pattern(state, node['number'])
          end

          super(node, state)
        end
      end

      # This replaces the converter
      ReverseAdoc::Converters.register :figure, Figure.new
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
stepmod-utils-0.4.14 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.4.13 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.4.12 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.4.11 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.4.10 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.4.9 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.4.8 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.4.7 lib/stepmod/utils/converters/figure.rb