Class: Vk::Photo
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#max_photo ⇒ String
Url to photo with maximum available size.
-
#max_photo_size ⇒ 75, ...
Maximum available picture size.
- #to_s ⇒ Object
- #uploaded_at ⇒ Object
Methods inherited from Base
#fields, find, #id, #id=, #identity_map, inherited, #initialize, #inspect, #key_field, #loader, #logger, method_missing, #method_missing, #read_attribute, #respond_to_missing?, #to_hash
Constructor Details
This class inherits a constructor from Vk::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Vk::Base
Instance Method Details
#max_photo ⇒ String
Returns url to photo with maximum available size.
28 29 30 |
# File 'lib/vk/photo.rb', line 28 def max_photo public_send("photo_#{max_photo_size}") end |
#max_photo_size ⇒ 75, ...
Returns maximum available picture size.
19 20 21 22 23 24 25 |
# File 'lib/vk/photo.rb', line 19 def max_photo_size @max_photo_size ||= attributes.keys.grep(/photo_/).inject(75) do |maximum, size| real_size = size.to_s.gsub(/\Aphoto_/, '').to_i real_size > maximum ? real_size : maximum end end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/vk/photo.rb', line 14 def to_s text.to_s end |
#uploaded_at ⇒ Object
10 11 12 |
# File 'lib/vk/photo.rb', line 10 def uploaded_at @uploaded_at ||= Time.at(read_attribute(:date)) end |