class JustimmoClient::V1::Attachment

Constants

BASE_URL

Public Instance Methods

[](size = nil)
Alias for: url
inspect() click to toggle source
# File lib/justimmo_client/api/v1/models/attachment.rb, line 38
def inspect
  "#<#{self.class} #{self}>"
end
to_s(size = nil)
Alias for: url
url(size = nil) click to toggle source
# File lib/justimmo_client/api/v1/models/attachment.rb, line 30
def url(size = nil)
  size ||= @size
  "#{BASE_URL}/#{@type}/#{size}/#{file}.#{format}"
end
Also aliased as: to_s, []
url=(value) click to toggle source

FIXME: the attachment can be something other than a image file

maybe move type detection into representer?
# File lib/justimmo_client/api/v1/models/attachment.rb, line 21
def url=(value)
  path = URI.parse(value).path.sub("/public/", "")
  @type, size, file = path.split("/")
  return if file.nil?
  @format ||= ::File.extname(file).tr(".", "")
  @file = ::File.basename(file, ".#{@format}")
  @size = size.start_with?("user") ? :user_big : :big
end