Class: Vk::Photo

Inherits:
Base
  • Object
show all
Defined in:
lib/vk/photo.rb

Instance Attribute Summary

Attributes inherited from Base

#attributes

Instance Method Summary collapse

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_photoString

Returns url to photo with maximum available size.

Returns:

  • (String)

    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_size75, ...

Returns maximum available picture size.

Returns:

  • (75, 130, 604, 807, 1280, 2560)

    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_sObject



14
15
16
# File 'lib/vk/photo.rb', line 14

def to_s
  text.to_s
end

#uploaded_atObject



10
11
12
# File 'lib/vk/photo.rb', line 10

def uploaded_at
  @uploaded_at ||= Time.at(read_attribute(:date))
end