Module: BEL::Gen::Citation
- Included in:
- Nanopub
- Defined in:
- lib/bel/gen/citation.rb
Overview
The Citation module defines methods that generate random citation fields. See #citation to generate a Nanopub::Citation.
Instance Method Summary collapse
-
#citation ⇒ BEL::Nanopub::Citation
Returns a random Nanopub::Citation.
-
#citation_authors ⇒ Array<String>
Returns a random Array of citation authors.
-
#citation_comment ⇒ String
Returns a random citation comment.
-
#citation_date ⇒ String
Returns a random citation date.
-
#citation_id ⇒ String
Returns a random citation id.
-
#citation_name ⇒ String
Returns a random citation name.
-
#citation_type ⇒ String
Returns a random citation type.
Instance Method Details
#citation ⇒ BEL::Nanopub::Citation
Returns a random Nanopub::Citation.
Note: This method has a good chance to return the last generated Nanopub::Citation. This behavior better models curated BEL nanopubs where many BEL statements have the same citation.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/bel/gen/citation.rb', line 73 def citation choice = @citation_hash == nil ? :new : Rantly { freq( [5, :literal, :reuse], [1, :literal, :new] ) } if choice == :new @citation_hash = { :type => citation_type, :name => citation_name, :id => citation_id, :date => citation_date, :authors => , :comment => citation_comment } end ::BEL::Nanopub::Citation.new(@citation_hash) end |
#citation_authors ⇒ Array<String>
Returns a random Array of citation authors.
47 48 49 50 51 52 53 |
# File 'lib/bel/gen/citation.rb', line 47 def Rantly { array(range(1, 5)) { "#{sized(6) { string(:alpha) }} #{sized(2) { string(:upper) }}" }.join('|') } end |
#citation_comment ⇒ String
Returns a random citation comment.
57 58 59 60 61 62 63 64 |
# File 'lib/bel/gen/citation.rb', line 57 def citation_comment Rantly { freq( [5, :literal, ''], [1, :literal, sized(50) { string(:alnum) }] ) } end |
#citation_date ⇒ String
Returns a random citation date.
41 42 43 |
# File 'lib/bel/gen/citation.rb', line 41 def citation_date '' end |
#citation_id ⇒ String
Returns a random citation id.
31 32 33 34 35 36 37 |
# File 'lib/bel/gen/citation.rb', line 31 def citation_id Rantly { sized(8) { string(:alnum) } } end |
#citation_name ⇒ String
Returns a random citation name.
21 22 23 24 25 26 27 |
# File 'lib/bel/gen/citation.rb', line 21 def citation_name Rantly { sized(32) { string(:alpha) } } end |
#citation_type ⇒ String
Returns a random citation type.
13 14 15 16 17 |
# File 'lib/bel/gen/citation.rb', line 13 def citation_type Rantly { choose('PubMed', 'Journal', 'Book', 'Online Resource', 'Other') } end |