Class: Kiva::Image
- Inherits:
-
Object
- Object
- Kiva::Image
- Includes:
- DynamicInitializer
- Defined in:
- lib/ruby-kiva/image.rb
Constant Summary collapse
- SIZES =
%w(w80h80 w200h200 w325h250 w450h360 fullsize)
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#template_id ⇒ Object
Returns the value of attribute template_id.
Instance Method Summary collapse
- #to_s ⇒ Object
-
#url(size = 'w80h80') ⇒ Object
Build the URL for this Image.
Methods included from DynamicInitializer
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/ruby-kiva/image.rb', line 4 def id @id end |
#template_id ⇒ Object
Returns the value of attribute template_id.
4 5 6 |
# File 'lib/ruby-kiva/image.rb', line 4 def template_id @template_id end |
Instance Method Details
#to_s ⇒ Object
8 9 10 |
# File 'lib/ruby-kiva/image.rb', line 8 def to_s "<Image #{self.template_id} / #{self.id}>" end |
#url(size = 'w80h80') ⇒ Object
Build the URL for this Image. See SIZES for valid sizes, defaults to w80h80
14 15 16 17 18 |
# File 'lib/ruby-kiva/image.rb', line 14 def url(size = 'w80h80') raise 'Must have a template id and an id' unless self.template_id && self.id raise "Unknown size #{size}" unless SIZES.include?(size.to_s) "http://www.kiva.org/img/#{size}/#{self.id}.jpg" end |