Class: JustimmoClient::V1::File
Direct Known Subclasses
Image
Constant Summary
collapse
- BASE_URL =
"https://files.justimmo.at/public"
Instance Method Summary
collapse
Methods included from Utils
#api, #autoload_dir, #interface, #model, #representer, #request, #translate, #versioned_api
Methods included from Logging
default_logger, #logger, rails_logger
Constructor Details
#initialize(**options) ⇒ File
Returns a new instance of File.
20
21
22
23
|
# File 'lib/justimmo_client/api/v1/models/file.rb', line 20
def initialize(**options)
super(options)
@settings = []
end
|
Instance Method Details
#add_url(url, default: nil) ⇒ Object
Also known as:
path=
46
47
48
49
50
51
52
|
# File 'lib/justimmo_client/api/v1/models/file.rb', line 46
def add_url(url, default: nil)
uri_path = URI.parse(url).path
@name ||= ::File.basename(uri_path)
@format ||= ::File.extname(@name)
@settings << ::URI.parse(url).path.split("/")[-2].to_sym
@default = default || @settings.last
end
|
#category ⇒ Symbol
12
|
# File 'lib/justimmo_client/api/v1/models/file.rb', line 12
attribute :category, Symbol
|
#category=(cat) ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/justimmo_client/api/v1/models/file.rb', line 25
def category=(cat)
@category =
case cat
when "BILD" then :image
when "TITELBILD" then :title_image
else nil
end
end
|
16
|
# File 'lib/justimmo_client/api/v1/models/file.rb', line 16
attribute :format, String
|
#get(setting = nil) ⇒ Object
Also known as:
[]
38
39
40
41
42
|
# File 'lib/justimmo_client/api/v1/models/file.rb', line 38
def get(setting = nil)
return nil if @default.nil? || @settings.empty?
setting = (@settings.include?(setting) ? setting : @default)
"#{BASE_URL}/#{@type}/#{setting}/#{@name}"
end
|
#inspect ⇒ Object
60
61
62
|
# File 'lib/justimmo_client/api/v1/models/file.rb', line 60
def inspect
"#<#{self.class} #{self}>"
end
|
#name ⇒ String
15
|
# File 'lib/justimmo_client/api/v1/models/file.rb', line 15
attribute :name, String
|
#origin ⇒ Symbol
13
|
# File 'lib/justimmo_client/api/v1/models/file.rb', line 13
attribute :origin, Symbol
|
#origin=(orig) ⇒ Object
34
35
36
|
# File 'lib/justimmo_client/api/v1/models/file.rb', line 34
def origin=(orig)
@origin = orig&.downcase&.to_sym
end
|
#title ⇒ String
11
|
# File 'lib/justimmo_client/api/v1/models/file.rb', line 11
attribute :title, String
|
#to_s ⇒ Object
56
57
58
|
# File 'lib/justimmo_client/api/v1/models/file.rb', line 56
def to_s
get
end
|
#type ⇒ Symbol
14
|
# File 'lib/justimmo_client/api/v1/models/file.rb', line 14
attribute :type, Symbol
|