Sha256: 69d1fab891bfb8859068bd6fe90ab99bd81bf262082726ec076a30efc22e8df4

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

module Stepmod
  module Utils

    class Concept
      attr_accessor *%w(
        designation
        definition
        reference_anchor
        reference_clause
        examples
        notes
        synonym
        converted_definition
        file_path
      )

      def initialize(options)
        options.each_pair do |k, v|
          send("#{k}=", v)
        end
      end

      def self.parse(definition_xml, reference_anchor:, reference_clause:, file_path:)
        converted_definition = Stepmod::Utils::StepmodDefinitionConverter
                                  .convert(definition_xml, { reference_anchor: reference_anchor })
        if definition_xml.name == 'arm' || definition_xml.name == 'ext_description'
          converted_definition = <<~TEXT
            #{converted_definition.split("\n")[0..3].join("\n")}

            NOTE: This term is incompletely defined in this document.
            Reference <<#{reference_anchor}>> for the complete definition.
          TEXT
        end
        new(
          converted_definition: converted_definition,
          reference_anchor: reference_anchor,
          reference_clause: reference_clause,
          file_path: file_path
        )
      end

      def to_mn_adoc
        <<~TEXT
          // STEPmod path: #{file_path}
          #{converted_definition}

          [.source]
          <<#{reference_anchor}#{reference_clause ? ",clause=" + reference_clause : ""}>>

        TEXT
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stepmod-utils-0.3.0 lib/stepmod/utils/concept.rb