Class: Snapfish::Asset
- Inherits:
-
Base
- Object
- Base
- Snapfish::Asset
show all
- Defined in:
- lib/snapfish/asset.rb
Instance Attribute Summary
Attributes inherited from Base
#json
Instance Method Summary
collapse
Methods inherited from Base
connection, connection=, #created_at, #initialize, #updated_at
Constructor Details
This class inherits a constructor from Snapfish::Base
Instance Method Details
#as_json(options = {}) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/snapfish/asset.rb', line 42
def as_json(options = {})
{
id: id,
ref: snapfish_ref,
filename: filename,
file_extension: file_extension,
width: width,
height: height,
size: size,
caption: caption,
url: hires_url
}
end
|
#caption ⇒ Object
30
31
32
|
# File 'lib/snapfish/asset.rb', line 30
def caption
('userTags', 'caption')
end
|
#file_extension ⇒ Object
34
35
36
|
# File 'lib/snapfish/asset.rb', line 34
def file_extension
File.extname(hires_url).downcase.gsub(/^\./, '')
end
|
#filename ⇒ Object
11
12
13
14
15
16
|
# File 'lib/snapfish/asset.rb', line 11
def filename
os_metadata = ('systemTags', 'OS_METADATA')
if os_metadata && os_metadata = os_metadata['value']
os_metadata.match(/os.fn=(\S+)/)[1]
end
end
|
#height ⇒ Object
26
27
28
|
# File 'lib/snapfish/asset.rb', line 26
def height
find_file('HIRES')['height']
end
|
#hires_url ⇒ Object
38
39
40
|
# File 'lib/snapfish/asset.rb', line 38
def hires_url
find_file('HIRES')['url']
end
|
#id ⇒ Object
3
4
5
|
# File 'lib/snapfish/asset.rb', line 3
def id
json['_id']
end
|
#size ⇒ Object
18
19
20
|
# File 'lib/snapfish/asset.rb', line 18
def size
json['files'].first['size']
end
|
#snapfish_ref ⇒ Object
7
8
9
|
# File 'lib/snapfish/asset.rb', line 7
def snapfish_ref
find_file('THUMBNAIL')['url']
end
|
#width ⇒ Object
22
23
24
|
# File 'lib/snapfish/asset.rb', line 22
def width
find_file('HIRES')['width']
end
|