module Markov

Constants

VERSION

markov version

Public Class Methods

generate(thing) click to toggle source
# File lib/markov.rb, line 11
def self.generate(thing)
  chain_for(thing).generate_word!.strip
end

Private Class Methods

chain_for(thing) click to toggle source
# File lib/markov.rb, line 20
def self.chain_for(thing)
  chains[thing] ||= load_chain(thing)
end
chains() click to toggle source
# File lib/markov.rb, line 16
def self.chains
  @chains ||= {}
end
load_chain(thing) click to toggle source
# File lib/markov.rb, line 24
def self.load_chain(thing)
  analysis_file = File.join(
    File.expand_path(File.dirname(__FILE__)),
    '..',
    'data',
    "#{thing}.json"
  )

  chain_data = File.read(analysis_file)
  Oj.load(chain_data)
end