Sha256: aee7d6af5ebf36d4f1e6d3d186350c94a5b99783faab3b4842d803f1d8dcfee6
Contents?: true
Size: 980 Bytes
Versions: 1
Compression:
Stored size: 980 Bytes
Contents
require 'vk/base' module Vk class Photo < Base self.fields = [ :id, :album_id, :owner_id, :user_id, :photo_75, :photo_130, :photo_604, :photo_807, :photo_1280, :photo_2560, :width, :height, :text, :date ] def uploaded_at @uploaded_at ||= Time.at(read_attribute(:date)) end def to_s text.to_s end # @return [75, 130, 604, 807, 1280, 2560] maximum available picture size 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 # @return [String] url to photo with maximum available size def max_photo public_send("photo_#{max_photo_size}") end protected def load_data(options = {}) @attributes = @attributes.merge(loader.get_group_by_id(id, options)) unless @attributes.size > 1 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vk-0.6.5.53 | lib/vk/photo.rb |