Class: Stepmod::Utils::Concept

Inherits:
Object
  • Object
show all
Defined in:
lib/stepmod/utils/concept.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Concept

Returns a new instance of Concept.



17
18
19
20
21
# File 'lib/stepmod/utils/concept.rb', line 17

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

Class Method Details

.parse(definition_xml, reference_anchor:, reference_clause:, file_path:) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/stepmod/utils/concept.rb', line 23

def self.parse(definition_xml, reference_anchor:, reference_clause:, file_path:)
  converted_definition = Stepmod::Utils::StepmodDefinitionConverter
                            .convert(definition_xml, { reference_anchor: reference_anchor })

  return nil if converted_definition.nil? || converted_definition.strip.empty?

  if definition_xml.name == 'uof' || 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

Instance Method Details

#to_mn_adoc ⇒ Object



45
46
47
48
49
50
51
52
53
54
# File 'lib/stepmod/utils/concept.rb', line 45

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

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

  TEXT
end