Sha256: 09c23bd8f7c29bce4f78eae43bfac3316737536798b2d0e6201c6ad5efc8b5d2

Contents?: true

Size: 975 Bytes

Versions: 20

Compression:

Stored size: 975 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

20 entries across 20 versions & 1 rubygems

Version Path
stepmod-utils-0.4.6 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.4.5 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.4.2 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.4.1 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.4.0 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.3.37 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.3.36 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.3.35 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.3.34 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.3.33 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.3.32 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.3.31 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.3.30 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.3.29 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.3.28 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.3.27 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.3.26 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.3.25 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.3.24 lib/stepmod/utils/converters/figure.rb
stepmod-utils-0.3.23 lib/stepmod/utils/converters/figure.rb