Class: Pastvu::Photo

Inherits:
Model
  • Object
show all
Defined in:
lib/pastvu/photo/photo.rb

Instance Method Summary collapse

Methods inherited from Model

#initialize, #to_hash, #to_json

Constructor Details

This class inherits a constructor from Pastvu::Model

Instance Method Details

#commentsObject



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

def comments
  Pastvu.comments @cid
end

#download(size, path) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
19
# File 'lib/pastvu/photo/photo.rb', line 14

def download(size, path)
  raise ArgumentError, "expect size to be correct symbol" unless %i[original standard thumbnail thumb].include?(size)
  raise ArgumentError, "expect file extension to be .jpeg or .jpg" unless path[-4..-1] == ".jpg" || path[-5..-1] == ".jpeg"

  Request.download(method(size).call, path)
end

#originalObject



25
26
27
# File 'lib/pastvu/photo/photo.rb', line 25

def original
  "https://pastvu.com/_p/a/".concat(file)
end

#reloadObject

VALID_ATTRIBUTES = %w[cid s file title dir geo year ccount] attr_accessor *VALID_ATTRIBUTES



6
7
8
# File 'lib/pastvu/photo/photo.rb', line 6

def reload
  Pastvu.photo @cid
end

#standardObject



21
22
23
# File 'lib/pastvu/photo/photo.rb', line 21

def standard
  "https://pastvu.com/_p/d/".concat(file)
end

#thumbObject



33
34
35
# File 'lib/pastvu/photo/photo.rb', line 33

def thumb
  thumbnail
end

#thumbnailObject



29
30
31
# File 'lib/pastvu/photo/photo.rb', line 29

def thumbnail
  "https://pastvu.com/_p/h/".concat(file)
end