Class: PlaceKitten
- Inherits:
-
Object
- Object
- PlaceKitten
- Defined in:
- lib/placekitten/placekitten.rb
Defined Under Namespace
Modules: Helpers
Constant Summary collapse
- DEFAULT_WIDTH =
300
- DEFAULT_HEIGHT =
300
Class Method Summary collapse
-
.grayscale(width = nil, height = nil) ⇒ Object
(also: gray)
Returns the URL for a grayscale placekitten with the given width and height.
-
.image(width = nil, height = nil, grayscale = false) ⇒ Object
(also: kitten)
Returns the URL for an optionally grayscale placekitten with the given width and height.
Class Method Details
.grayscale(width = nil, height = nil) ⇒ Object Also known as: gray
Returns the URL for a grayscale placekitten with the given width and height. If the width is given but the height is not, the image will be square.
33 34 35 |
# File 'lib/placekitten/placekitten.rb', line 33 def self.grayscale(width = nil, height = nil) self.image(width, height, true) end |
.image(width = nil, height = nil, grayscale = false) ⇒ Object Also known as: kitten
Returns the URL for an optionally grayscale placekitten with the given width and height. If the width is given but the height is not, the image will be square.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/placekitten/placekitten.rb', line 12 def self.image(width = nil, height = nil, grayscale = false) if width.nil? width = DEFAULT_WIDTH height = DEFAULT_HEIGHT elsif height.nil? height = width end if grayscale "http://placekitten.com/g/#{width}/#{height}" else "http://placekitten.com/#{width}/#{height}" end end |