Class: LoremIpsum

Inherits:
Object
  • Object
show all
Defined in:
lib/lorem-ipsum.rb

Class Method Summary collapse

Class Method Details

.generate(options = {}) ⇒ Object

Our defacto method.

All arguments are optional

:language => XML, JSON or text
:format => Plain or HTML
:type => Essay or Blog


13
14
15
16
17
18
19
20
21
22
# 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