Class: JustimmoClient::V1::Attachment

Inherits:
JustimmoBase show all
Defined in:
lib/justimmo_client/api/v1/models/attachment.rb

Instance Method Summary collapse

Methods included from Utils

#autoload_dir, #translate

Methods included from Logging

default_logger, #logger, rails_logger

Instance Method Details

#inspectObject



34
35
36
# File 'lib/justimmo_client/api/v1/models/attachment.rb', line 34

def inspect
  "#<#{self.class} #{self}>"
end

#url(size = nil) ⇒ Object Also known as: to_s, []



26
27
28
29
# File 'lib/justimmo_client/api/v1/models/attachment.rb', line 26

def url(size = nil)
  size ||= @size
  "#{BASE_URL}/#{@type}/#{size}/#{file}.#{format}"
end

#url=(value) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/justimmo_client/api/v1/models/attachment.rb', line 18

def url=(value)
  path = URI.parse(value).path.sub("/public/", "")
  @type, size, file = path.split("/")
  @format ||= ::File.extname(file).tr(".", "")
  @file = ::File.basename(file, ".#{@format}")
  @size = size.start_with?("user") ? :user_big : :big
end