class LoremIpsumBio

The main Lorem Ipsum Bio class

Public Class Methods

random_DNA(n) click to toggle source

Generate random DNA fragment

Example:

>> LoremIpsumBio.random_DNA(3)
=> "TGA"

Arguments:

n: (Integer)
# File lib/lorem_ipsum_bio.rb, line 30
def self.random_DNA(n)
  random_string(n, ['A', 'C', 'G', 'T'])
end
random_RNA(n) click to toggle source

Generate random RNA fragment

Example:

>> LoremIpsumBio.random_RNA(3)
=> "UGA"

Arguments:

n: (Integer)
# File lib/lorem_ipsum_bio.rb, line 42
def self.random_RNA(n)
  random_string(n, ['A', 'C', 'G', 'U'])
end
random_protein(n) click to toggle source

Generate random protein fragment

Example:

>> LoremIpsumBio.random_protein(3)
=> "WTF"

Arguments:

n: (Integer)
# 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_string(n, a) click to toggle source

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)
# 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