Class: Relaton::Ietf::Rfc::Entry

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/relaton/ietf/rfc/entry.rb

Overview

Model for index entries (bcp-entry, fyi-entry, std-entry, rfc-entry)

Constant Summary collapse

TITLE_PREFIXES =

rubocop:disable Metrics/ClassLength

{
  "bcp" => "Best Current Practice",
  "fyi" => "For Your Information",
  "std" => "Internet Standard technical specification",
}.freeze

Instance Method Summary collapse

Instance Method Details

#anchorString

Generate anchor string (e.g., “BCP1”)

Returns:

  • (String)

    anchor



114
115
116
# File 'lib/relaton/ietf/rfc/entry.rb', line 114

def anchor
  "#{entry_type&.upcase}#{shortnum}"
end

#entry_typeString?

Determine entry type from doc-id prefix

Returns:

  • (String, nil)

    entry type (bcp, fyi, std, rfc)



78
79
80
# File 'lib/relaton/ietf/rfc/entry.rb', line 78

def entry_type
  doc_id&.downcase&.match(/^(bcp|fyi|std|rfc)/)&.[](1)
end

#has_is_also?Boolean

Check if this entry has is-also references

Returns:

  • (Boolean)


123
124
125
# File 'lib/relaton/ietf/rfc/entry.rb', line 123

def has_is_also?
  is_also&.doc_id&.any? || false
end

#pub_idString

Generate public identifier (e.g., “BCP 1”)

Returns:

  • (String)

    public identifier



105
106
107
# File 'lib/relaton/ietf/rfc/entry.rb', line 105

def pub_id
  "#{entry_type&.upcase} #{shortnum}"
end

#rfc_entry?Boolean

Check if this is an rfc-entry

Returns:

  • (Boolean)


87
88
89
# File 'lib/relaton/ietf/rfc/entry.rb', line 87

def rfc_entry?
  entry_type == "rfc"
end

#shortnumString

Extract short number from doc-id (e.g., “BCP0001” -> “1”)

Returns:

  • (String)

    short number without leading zeros



96
97
98
# File 'lib/relaton/ietf/rfc/entry.rb', line 96

def shortnum
  doc_id&.match(/\d+$/)&.to_s&.sub(/^0+/, "") || ""
end

#to_item(rfc_index = nil, wg_names: {}) ⇒ Relaton::Ietf::ItemData?

Convert to Relaton::Ietf::ItemData

Parameters:

  • rfc_index (Hash{String => Entry}, nil) (defaults to: nil)

    lookup of RFC entries by doc-id

Returns:



133
134
135
136
137
138
139
# File 'lib/relaton/ietf/rfc/entry.rb', line 133

def to_item(rfc_index = nil, wg_names: {})
  if rfc_entry?
    to_rfc_item(wg_names: wg_names)
  else
    to_subseries_item(rfc_index, wg_names: wg_names)
  end
end

#to_rfc_item(wg_names: {}) ⇒ Object

rubocop:disable Metrics/MethodLength



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/relaton/ietf/rfc/entry.rb', line 141

def to_rfc_item(wg_names: {}) # rubocop:disable Metrics/MethodLength
  args = {
    type: "standard",
    language: ["en"],
    script: ["Latn"],
    docidentifier: build_rfc_docid,
    docnumber: doc_id,
    title: build_rfc_title,
    source: build_rfc_link,
    date: build_rfc_date,
    contributor: build_rfc_contributor(wg_names),
    status: build_rfc_status,
    keyword: build_rfc_keyword,
    abstract: build_rfc_abstract,
    relation: build_rfc_relation,
    series: build_rfc_series,
    ext: build_rfc_ext,
  }
  ItemData.new(**args)
end