Class: Orly::Book
- Inherits:
-
Object
- Object
- Orly::Book
- Defined in:
- lib/orly/book.rb,
lib/orly/book/version.rb
Constant Summary collapse
- VERSION =
"0.4.0"
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(filename = "orly", options = {}) ⇒ Book
constructor
A new instance of Book.
Constructor Details
#initialize(filename = "orly", options = {}) ⇒ Book
Returns a new instance of Book.
6 7 8 9 10 11 12 13 14 |
# File 'lib/orly/book.rb', line 6 def initialize(filename="orly", ={}) @filename = filename @title = URI.encode([:title]) || "%20" @top_text = URI.encode([:top_text]) || "%20" = URI.encode([:author]) || "%20" @theme = [:theme] || rand(17) @animal = [:animal] || rand(40)+1 generate end |
Instance Method Details
#generate ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/orly/book.rb', line 16 def generate puts "Starting" # uri = URI("http://orly-appstore.herokuapp.com Net::HTTP.start("orly-appstore.herokuapp.com") do |http| resp = http.get("/generate?title=#{@title}&top_text=#{@top_text}&author=#{@author}&theme=#{@theme}&image_code=#{@animal}") open("./#{@filename}.png", "wb") do |file| file.write(resp.body) end end puts "Done!" end |