Module: BEL::Gen::Parameter
Overview
The Parameter module defines methods that generate random BEL parameters.
Constant Summary
Constants included from Namespace
Instance Method Summary collapse
-
#bel_parameter ⇒ BEL::Nanopub::Parameter
Returns a BEL parameter that may or may not have a namespace.
-
#bel_parameter_with_namespace ⇒ BEL::Nanopub::Parameter
Returns a BEL parameter from a random namespace.
-
#bel_parameter_without_namespace ⇒ BEL::Nanopub::Parameter
Returns a BEL parameter without a namespace.
Methods included from Namespace
#namespace, #referenced_namespaces
Instance Method Details
#bel_parameter ⇒ BEL::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.
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_namespace ⇒ BEL::Nanopub::Parameter
Returns a BEL parameter from a random namespace. The value will be a random string and not necessarily part of the namespace.
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_namespace ⇒ BEL::Nanopub::Parameter
Returns a BEL parameter without a namespace. The value will be a random string.
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 |