Module: RelatonIec
- Defined in:
- lib/relaton_iec.rb,
lib/relaton_iec/hit.rb,
lib/relaton_iec/util.rb,
lib/relaton_iec/index.rb,
lib/relaton_iec/version.rb,
lib/relaton_iec/processor.rb,
lib/relaton_iec/xml_parser.rb,
lib/relaton_iec/data_parser.rb,
lib/relaton_iec/data_fetcher.rb,
lib/relaton_iec/document_type.rb,
lib/relaton_iec/hash_converter.rb,
lib/relaton_iec/hit_collection.rb,
lib/relaton_iec/basic_block/eref.rb,
lib/relaton_iec/iec_bibliography.rb,
lib/relaton_iec/tc_sc_officers_note.rb,
lib/relaton_iec/basic_block/eref_type.rb,
lib/relaton_iec/iec_bibliographic_item.rb,
lib/relaton_iec/basic_block/citation_type.rb,
lib/relaton_iec/basic_block/reference_format.rb
Defined Under Namespace
Modules: HashConverter, Util Classes: CitationType, DataFetcher, DataParser, DocumentType, Eref, ErefType, Hit, HitCollection, IecBibliographicItem, IecBibliography, Index, Processor, ReferenceFormat, TcScOfficersNote, XMLParser
Constant Summary collapse
- VERSION =
"1.20.0".freeze
Class Method Summary collapse
- .code_to_urn(code, lang = nil) ⇒ String?
-
.grammar_hash ⇒ String
Returns hash of XML reammar.
- .method_missing(_method, *args) ⇒ Object
- .respond_to_missing?(method, _include_private) ⇒ Boolean
-
.urn_to_code(urn) ⇒ Array<String>?
Urn & language.
Class Method Details
.code_to_urn(code, lang = nil) ⇒ String?
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/relaton_iec.rb', line 34 def code_to_urn(code, lang = nil) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength rest = code.downcase.sub(%r{ (?<head>[^\s]+)\s (?<type>is|ts|tr|pas|srd|guide|tec|wp)?(?(<type>)\s) (?<pnum>[\d-]+)\s? (?<_dd>:)?(?(<_dd>)(?<date>[\d-]+)\s?) }x, "") m = $~ return unless m[:head] && m[:pnum] deliv = /cmv|csv|exv|prv|rlv|ser/.match(code.downcase).to_s urn = ["urn", "iec", "std", m[:head].split("/").join("-"), m[:pnum], m[:date], m[:type], deliv, lang] (urn + ajunct_to_urn(rest)).join ":" end |
.grammar_hash ⇒ String
Returns hash of XML reammar
24 25 26 27 28 29 |
# File 'lib/relaton_iec.rb', line 24 def grammar_hash # gem_path = File.expand_path "..", __dir__ # grammars_path = File.join gem_path, "grammars", "*" # grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join Digest::MD5.hexdigest RelatonIec::VERSION + RelatonIsoBib::VERSION + RelatonBib::VERSION # grammars end |
.method_missing(_method, *args) ⇒ Object
6 7 8 |
# File 'lib/relaton_iec/basic_block/reference_format.rb', line 6 def self.method_missing(_method, *args) ReferenceFormat.new(*args) end |
.respond_to_missing?(method, _include_private) ⇒ Boolean
2 3 4 |
# File 'lib/relaton_iec/basic_block/reference_format.rb', line 2 def self.respond_to_missing?(method, _include_private) method == "ReferenceFormat" end |
.urn_to_code(urn) ⇒ Array<String>?
Returns urn & language.
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/relaton_iec.rb', line 51 def urn_to_code(urn) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity fields = urn.upcase.split ":" return if fields.size < 5 head, num, date, type, deliv, lang = fields[3, 8] code = head.gsub("-", "/") code += " #{type}" unless type.nil? || type.empty? code += " #{num}" code += ":#{date}" unless date.nil? || date.empty? code += ajanct_to_code(fields[9..-1]) code += " #{deliv}" unless deliv.nil? || deliv.empty? [code, lang&.downcase] end |