Dicom_UID 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/dicom_uid.rb +39 -0
  3. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6f9a46a74a04042d1b61ef8f4936e19f0440a55c0901c41f49723147d6ec8ca2
4
+ data.tar.gz: 412ad044741722608ef1827da42fcbe5f89fb9cd4aae60416c75897247cf6c07
5
+ SHA512:
6
+ metadata.gz: e9d66b52333390bbce6f243aed66a908d8aedecd05890e08284771ca9334e174140fa79f9e45356871a2713debb6d2dcf06c7e08ca6fe20044b7a98d075831cf
7
+ data.tar.gz: 0b0b73567ccf0889b5cd214da19634f46c932fbd84eec54820938a2d0e7cdb8f1d88a810ed73bd54f5d72ffb27a42e2035a9ba492e178ffa9c74fb65f5ba554a
data/lib/dicom_uid.rb ADDED
@@ -0,0 +1,39 @@
1
+ # lib/dicom_uid.rb
2
+ class DicomUID
3
+
4
+
5
+ # Generates random component with random, defined, length
6
+ def self.random_component length = 64
7
+ # randing length of number
8
+ length_component = length - 1
9
+ loop do
10
+ srand
11
+ length_component = rand(0..length)
12
+ break if length_component != length - 1 and length_component != 0
13
+ end
14
+
15
+ # randing the component
16
+ (rand ('9' * length_component).to_i).to_s
17
+ end
18
+
19
+
20
+ # Generate recursively a random dicom uid
21
+ def self.rand_duid uid = '', remain
22
+ comp = self.random_component remain
23
+ remain -= comp.length
24
+ uid << comp
25
+
26
+ return uid if remain <= 0
27
+
28
+ uid << '.'
29
+ self.rand_duid uid, remain - 1
30
+ end
31
+
32
+
33
+ # set default values, with org_root if needed
34
+ def self.random_dicom_uid org_root = '', size = 64
35
+ org_root << '.' if !org_root.empty? and org_root[-1] != '.'
36
+ return self.rand_duid org_root, size
37
+ end
38
+
39
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Dicom_UID
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Repain Paul
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-05-08 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Generates random uid for DICOM files
14
+ email: paul.repain@yahoo.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/dicom_uid.rb
20
+ homepage: https://rubygems.org/gems/dicom_uid
21
+ licenses:
22
+ - MIT
23
+ metadata:
24
+ source_code_uri: https://github.com/Poulpy/dicom_uid
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.7.9
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: 4027613897609896144885579817926891251.445655382004259.49.58879.6
45
+ test_files: []