class LoremIpsum

Public Class Methods

generate(options = {}) click to toggle source

Our defacto method.

All arguments are optional

:language => XML, JSON or text
:format => Plain or HTML
:type => Essay or Blog
# File lib/lorem-ipsum.rb, line 13
def self.generate(options = {})
  options[:language]  ||= "text" # XML, JSON or Text
  options[:format]    ||= "plain" # Plain or HTML
  options[:type]      ||= "essay" # Essay or Blog

  # http://lorem-ipsum.me/api/xml?format=plain&type=blog
  uri       = "http://lorem-ipsum.me/api/#{options[:language]}?format=#{options[:format]}&type=#{options[:type]}"
  request   = URI.parse(uri)
  response  = Net::HTTP.get_response(request).body
end