Class: LoremIpsumBio
- Inherits:
-
Object
- Object
- LoremIpsumBio
- Defined in:
- lib/lorem_ipsum_bio.rb
Overview
The main Lorem Ipsum Bio class
Class Method Summary collapse
-
.random_DNA(n) ⇒ Object
Generate random DNA fragment.
-
.random_protein(n) ⇒ Object
Generate random protein fragment.
-
.random_RNA(n) ⇒ Object
Generate random RNA fragment.
-
.random_string(n, a) ⇒ Object
Generate random string by sampling an array.
Class Method Details
.random_DNA(n) ⇒ Object
Generate random DNA fragment
Example:
>> LoremIpsumBio.random_DNA(3)
=> "TGA"
Arguments:
n: (Integer)
30 31 32 |
# File 'lib/lorem_ipsum_bio.rb', line 30 def self.random_DNA(n) random_string(n, ['A', 'C', 'G', 'T']) end |
.random_protein(n) ⇒ Object
Generate random protein fragment
Example:
>> LoremIpsumBio.random_protein(3)
=> "WTF"
Arguments:
n: (Integer)
54 55 56 57 58 59 60 |
# File 'lib/lorem_ipsum_bio.rb', line 54 def self.random_protein(n) random_string(n, ['A', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'W', 'V', 'Y']) end |
.random_RNA(n) ⇒ Object
Generate random RNA fragment
Example:
>> LoremIpsumBio.random_RNA(3)
=> "UGA"
Arguments:
n: (Integer)
42 43 44 |
# File 'lib/lorem_ipsum_bio.rb', line 42 def self.random_RNA(n) random_string(n, ['A', 'C', 'G', 'U']) end |
.random_string(n, a) ⇒ Object
Generate random string by sampling an array
Examples:
>> LoremIpsumBio.random_string(3, ['a', 'b', 'c'])
=> "bac"
>> LoremIpsumBio.random_string(2, ['who', 'am', 'I'])
=> "Iam"
Arguments:
n: (Integer)
a: (Array)
15 16 17 18 19 20 |
# File 'lib/lorem_ipsum_bio.rb', line 15 def self.random_string(n, a) out_str = '' n.times { out_str << a.sample } out_str end |