class Lyracyst::Rhymebrain::Combine
Fetches portmanteaus using the Rhymebrain
API.
Public Instance Methods
comb_extra(result)
click to toggle source
Extra repetitive tasks
@param result [Array] List of hashes to process.
# File lib/lyracyst/rhymebrain/combine.rb, line 27 def comb_extra(result) a, b, pmcont, label = 0, result.length - 1, [], 'Portmanteau' while a <= b match = result[a] roots = match['source'] combo = match['combined'] both = "#{Rainbow('Root words|').bright}#{roots}#{Rainbow('Combination|').bright}#{combo}" roots = { 'roots' => roots } combo = { 'combo' => combo } Lyracyst.tofile(roots) Lyracyst.tofile(combo) pmcont.push both a += 1 end Lyracyst.label(label) puts pmcont.join(Rainbow('|').bright) end
get_port(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/combine.rb, line 10 def get_port(search, params) func, result = 'Portmanteaus', nil pm = Lyracyst::Rhymebrain.new result = pm.get_word(search, func, params, result) result = MultiJson.load(result) if result != nil type = { 'type' => 'portmanteau' } st = { 'searchterm' => search } Lyracyst.tofile(st) Lyracyst.tofile(type) e = Lyracyst::Rhymebrain::Combine.new e.comb_extra(result) end end