Sha256: 9e87e2cde067710fdd900bd8144eab35b99f65cf5dd1c129172411fef7f10e0c

Contents?: true

Size: 618 Bytes

Versions: 26

Compression:

Stored size: 618 Bytes

Contents

# frozen_string_literal: true

module Glossarist
  class RelatedConcept < Model
    include Glossarist::Utilities::Enum

    register_enum :type, Glossarist::GlossaryDefinition::RELATED_CONCEPT_TYPES

    # @return [String]
    attr_accessor :content

    # Reference to the related concept.
    # @return [Citation]
    attr_reader :ref

    def ref=(ref)
      @ref = Citation.new(ref)
    end

    def to_h
      reference = ref&.to_h
      reference&.merge!(reference&.delete("ref"))

      {
        "type" => type.to_s,
        "content" => content,
        "ref" => reference,
      }.compact
    end
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
glossarist-2.3.0 lib/glossarist/related_concept.rb
glossarist-2.2.1 lib/glossarist/related_concept.rb
glossarist-2.2.0 lib/glossarist/related_concept.rb
glossarist-2.1.0 lib/glossarist/related_concept.rb
glossarist-2.0.10 lib/glossarist/related_concept.rb
glossarist-2.0.9 lib/glossarist/related_concept.rb
glossarist-2.0.8 lib/glossarist/related_concept.rb
glossarist-2.0.7 lib/glossarist/related_concept.rb
glossarist-2.0.6 lib/glossarist/related_concept.rb
glossarist-2.0.5 lib/glossarist/related_concept.rb
glossarist-2.0.4 lib/glossarist/related_concept.rb
glossarist-2.0.3 lib/glossarist/related_concept.rb
glossarist-2.0.2 lib/glossarist/related_concept.rb
glossarist-2.0.1 lib/glossarist/related_concept.rb
glossarist-2.0.0 lib/glossarist/related_concept.rb
glossarist-1.1.0 lib/glossarist/related_concept.rb
glossarist-1.0.9 lib/glossarist/related_concept.rb
glossarist-1.0.8 lib/glossarist/related_concept.rb
glossarist-1.0.7 lib/glossarist/related_concept.rb
glossarist-1.0.6 lib/glossarist/related_concept.rb