Class: Contentful::Asset
- Inherits:
-
FieldsResource
- Object
- BaseResource
- FieldsResource
- Contentful::Asset
- Includes:
- ResourceReferences
- Defined in:
- lib/contentful/asset.rb
Overview
Resource class for Asset. www.contentful.com/developers/documentation/content-delivery-api/#assets
Instance Attribute Summary
Attributes inherited from FieldsResource
Attributes inherited from BaseResource
#_metadata, #default_locale, #raw, #sys
Instance Method Summary collapse
-
#image_url(options = {}) ⇒ String
(also: #url)
Generates a URL for the Contentful Image API.
-
#initialize ⇒ Asset
constructor
A new instance of Asset.
- #inspect ⇒ Object
- #known_link? ⇒ Boolean
- #marshal_dump ⇒ Object
- #marshal_load(raw_object) ⇒ Object
Methods included from ResourceReferences
Methods inherited from FieldsResource
#fields, #fields_with_locales, #locales, #raw_with_links
Methods inherited from BaseResource
Constructor Details
#initialize ⇒ Asset
Returns a new instance of Asset.
33 34 35 36 37 |
# File 'lib/contentful/asset.rb', line 33 def initialize(*) super create_files! define_asset_methods! end |
Instance Method Details
#image_url(options = {}) ⇒ String Also known as: url
Generates a URL for the Contentful Image API
53 54 55 56 57 58 59 60 61 |
# File 'lib/contentful/asset.rb', line 53 def image_url( = {}) query = build_query() if query.empty? file.url else "#{file.url}?#{URI.encode_www_form(query)}" end end |
#inspect ⇒ Object
29 30 31 |
# File 'lib/contentful/asset.rb', line 29 def inspect "<#{repr_name} id='#{sys[:id]}' url='#{url}'>" end |
#known_link? ⇒ Boolean
24 25 26 |
# File 'lib/contentful/asset.rb', line 24 def known_link?(*) false end |
#marshal_dump ⇒ Object
12 13 14 |
# File 'lib/contentful/asset.rb', line 12 def marshal_dump super.merge(raw: raw) end |
#marshal_load(raw_object) ⇒ Object
17 18 19 20 21 |
# File 'lib/contentful/asset.rb', line 17 def marshal_load(raw_object) super(raw_object) create_files! define_asset_methods! end |