Class: JustimmoClient::V1::Attachment
- Inherits:
-
JustimmoBase
- Object
- JustimmoBase
- JustimmoClient::V1::Attachment
- Defined in:
- lib/justimmo_client/api/v1/models/attachment.rb
Instance Method Summary collapse
- #inspect ⇒ Object
- #url(size = nil) ⇒ Object (also: #to_s, #[])
-
#url=(value) ⇒ Object
FIXME: the attachment can be something other than a image file maybe move type detection into representer?.
Methods inherited from JustimmoBase
Methods included from Utils
Methods included from Logging
default_logger, #logger, rails_logger
Instance Method Details
#inspect ⇒ Object
38 39 40 |
# File 'lib/justimmo_client/api/v1/models/attachment.rb', line 38 def inspect "#<#{self.class} #{self}>" end |
#url(size = nil) ⇒ Object Also known as: to_s, []
30 31 32 33 |
# File 'lib/justimmo_client/api/v1/models/attachment.rb', line 30 def url(size = nil) size ||= @size "#{BASE_URL}/#{@type}/#{size}/#{file}.#{format}" end |
#url=(value) ⇒ Object
FIXME: the attachment can be something other than a image file
maybe move type detection into representer?
21 22 23 24 25 26 27 28 |
# 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 |