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
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.
Methods included from ResourceReferences
Methods inherited from FieldsResource
#fields, #fields_with_locales, #locales
Methods inherited from BaseResource
Constructor Details
#initialize ⇒ Asset
Returns a new instance of Asset
31 32 33 34 35 |
# File 'lib/contentful/asset.rb', line 31 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
51 52 53 54 55 56 57 58 59 |
# File 'lib/contentful/asset.rb', line 51 def image_url( = {}) query = build_query() if query.empty? file.url else "#{file.url}?#{URI.encode_www_form(query)}" end end |