Module: BEL::Gen::Parameter

Includes:
Namespace
Included in:
Nanopub, Term
Defined in:
lib/bel/gen/parameter.rb

Overview

The Parameter module defines methods that generate random BEL parameters.

Constant Summary

Constants included from Namespace

Namespace::NAMESPACES

Instance Method Summary collapse

Methods included from Namespace

#namespace, #referenced_namespaces

Instance Method Details

#bel_parameterBEL::Nanopub::Parameter

Returns a BEL parameter that may or may not have a namespace.

Note: This method has a better chance of selecting a BEL parameter with a namespace.

Returns:

See Also:



59
60
61
62
63
64
65
66
67
68
# File 'lib/bel/gen/parameter.rb', line 59

def bel_parameter
  with_namespace    = bel_parameter_with_namespace
  without_namespace = bel_parameter_without_namespace
  Rantly {
    freq(
      [5, :literal, with_namespace],
      [1, :literal, without_namespace],
    )
  }
end

#bel_parameter_with_namespaceBEL::Nanopub::Parameter

Returns a BEL parameter from a random namespace. The value will be a random string and not necessarily part of the namespace.

Returns:



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/bel/gen/parameter.rb', line 18

def bel_parameter_with_namespace
  ns    = namespace
  value = Rantly.value {
    sized(range(3,10)) {
      string(/[[:alnum:]]|[[:blank:]]|[[:punct:]]/)
    }
  }
  BEL::Nanopub::Parameter.new(
    ns,
    value,
    :A
  )
end

#bel_parameter_without_namespaceBEL::Nanopub::Parameter

Returns a BEL parameter without a namespace. The value will be a random string.

Returns:



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/bel/gen/parameter.rb', line 37

def bel_parameter_without_namespace
  value = Rantly.value {
    sized(range(3,10)) {
      string(/[[:alnum:]]|[[:blank:]]|[[:punct:]]/)
    }
  }
  BEL::Nanopub::Parameter.new(
    nil,
    value,
    :A
  )
end