Class: LoremIpsum
- Inherits:
-
Object
- Object
- LoremIpsum
- Defined in:
- lib/lorem-ipsum.rb
Class Method Summary collapse
-
.generate(options = {}) ⇒ Object
Our defacto method.
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( = {}) [:language] ||= "text" # XML, JSON or Text [:format] ||= "plain" # Plain or HTML [:type] ||= "essay" # Essay or Blog # http://lorem-ipsum.me/api/xml?format=plain&type=blog uri = "http://lorem-ipsum.me/api/#{[:language]}?format=#{[:format]}&type=#{[:type]}" request = URI.parse(uri) response = Net::HTTP.get_response(request).body end |