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

Instance Method Details

#citationBEL::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.

Returns:



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 => citation_authors,
      :comment => citation_comment
    }
  end

  ::BEL::Nanopub::Citation.new(@citation_hash)
end

#citation_authorsArray<String>

Returns a random Array of citation authors.

Returns:

  • (Array<String>)

    a random Array of citation authors



47
48
49
50
51
52
53
# File 'lib/bel/gen/citation.rb', line 47

def citation_authors
  Rantly {
    array(range(1, 5)) {
      "#{sized(6) { string(:alpha) }} #{sized(2) { string(:upper) }}"
    }.join('|')
  }
end

#citation_commentString

Returns a random citation comment.

Returns:

  • (String)

    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_dateString

Returns a random citation date.

Returns:

  • (String)

    a random citation date



41
42
43
# File 'lib/bel/gen/citation.rb', line 41

def citation_date
  ''
end

#citation_idString

Returns a random citation id.

Returns:

  • (String)

    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_nameString

Returns a random citation name.

Returns:

  • (String)

    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_typeString

Returns a random citation type.

Returns:

  • (String)

    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