class Lyracyst::Rhymebrain::Rhyme
Fetches rhymes using the Rhymebrain
API.
Public Instance Methods
get_rhyme(search, params)
click to toggle source
@param search [String] The word or phrase to search for. @param params [Hash] The search parameters to use.
# File lib/lyracyst/rhymebrain/rhyme.rb, line 10 def get_rhyme(search, params) func, label, result = 'Rhymes', 'Rhymes', nil rh = Lyracyst::Rhymebrain.new result = rh.get_word(search, func, params, result) result = MultiJson.load(result) if result != nil Lyracyst.label(label) type = { 'type' => 'rhyme' } st = { 'searchterm' => search } Lyracyst.tofile(st) Lyracyst.tofile(type) e = Lyracyst::Rhymebrain::Rhyme.new e.rhyme_extra(result) end end
rhyme_extra(result)
click to toggle source
Extra repetitive tasks.
@param result [Array] List of hashes to process.
# File lib/lyracyst/rhymebrain/rhyme.rb, line 28 def rhyme_extra(result) a, b, rcont = 0, result.length - 1, [] while a <= b match = result[a] rhyme = match['word'] rcont.push rhyme rhyme = { 'rhyme' => rhyme } a += 1 end Lyracyst.tofile("#{rcont.join(',')}") puts rcont.join(Rainbow('|').bright) end