Class: ACTV::Asset
Constant Summary
ACTV::AssetSourceSystem::SOURCE_SYSTEM_HASH
Instance Attribute Summary collapse
Attributes inherited from Base
#attrs
Class Method Summary
collapse
Instance Method Summary
collapse
-
#attribute_paths ⇒ Object
-
#attributes ⇒ Object
-
#category_is?(name) ⇒ Boolean
-
#channels ⇒ Object
(also: #asset_channels, #assetChannels)
-
#components ⇒ Object
(also: #asset_components, #assetComponents)
-
#description ⇒ Object
-
#description_by_type(type) ⇒ Object
-
#descriptions ⇒ Object
(also: #asset_descriptions, #assetDescriptions)
-
#endurance_id ⇒ Object
-
#evergreen? ⇒ Boolean
-
#first_topic ⇒ Object
(also: #topic)
-
#first_topic_name ⇒ Object
-
#first_topic_path ⇒ Object
-
#has_location? ⇒ Boolean
-
#has_volume_based_price? ⇒ Boolean
-
#image ⇒ Object
-
#image_by_name(name) ⇒ Object
-
#image_path ⇒ Object
-
#image_with_placeholder ⇒ Object
-
#images ⇒ Object
(also: #asset_images, #assetImages)
-
#initialize(options = {}) ⇒ Asset
constructor
-
#is_article? ⇒ Boolean
-
#is_event? ⇒ Boolean
-
#is_video? ⇒ Boolean
-
#kids? ⇒ Boolean
-
#legacy_data ⇒ Object
(also: #asset_legacy_data, #assetLegacyData)
-
#location_path ⇒ Object
-
#media_url ⇒ Object
-
#meta_interest_paths ⇒ Object
-
#meta_interests ⇒ Object
-
#org_timezone ⇒ Object
-
#organization ⇒ Object
-
#place ⇒ Object
-
#place_timezone ⇒ Object
-
#prices ⇒ Object
(also: #asset_prices, #assetPrices)
-
#recurrences ⇒ Object
-
#references ⇒ Object
-
#registration_status ⇒ Object
(also: #reg_status)
-
#seo_url(systemName = 'as3') ⇒ Object
-
#seo_urls ⇒ Object
(also: #asset_seo_urls, #assetSeoUrls)
-
#sponsored? ⇒ Boolean
-
#status ⇒ Object
(also: #asset_status, #assetStatus)
-
#sub_2_topic ⇒ Object
-
#sub_2_topic_path ⇒ Object
-
#sub_3_topic ⇒ Object
-
#sub_3_topic_path ⇒ Object
-
#sub_4_topic ⇒ Object
-
#sub_4_topic_path ⇒ Object
-
#sub_topic ⇒ Object
-
#sub_topic_path ⇒ Object
-
#summary ⇒ Object
-
#tag_by_description(description) ⇒ Object
-
#tags ⇒ Object
(also: #asset_tags, #assetTags)
-
#topics ⇒ Object
(also: #asset_topics, #assetTopics)
-
#version ⇒ Object
-
#visible? ⇒ Boolean
#kids_friendly_source_system?
Methods inherited from Identity
#==
Methods inherited from Base
#[], attr_reader, define_attribute_method, define_predicate_method, define_uri_method, #delete, #memoize, #method_missing, object_attr_reader, #respond_to?, #to_hash, #update, uri_attr_reader
Constructor Details
#initialize(options = {}) ⇒ Asset
Returns a new instance of Asset.
51
52
53
54
|
# File 'lib/actv/asset.rb', line 51
def initialize options={}
super
options[:logoUrlAdr]= replace_http_to_https options[:logoUrlAdr]
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class ACTV::Base
Instance Attribute Details
#activityEndDate ⇒ Object
Also known as:
end_date, activity_end_date
Returns the value of attribute activityEndDate.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def activityEndDate
@activityEndDate
end
|
#activityEndTime ⇒ Object
Also known as:
end_time
Returns the value of attribute activityEndTime.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def activityEndTime
@activityEndTime
end
|
#activityStartDate ⇒ Object
Also known as:
start_date, activity_start_date
Returns the value of attribute activityStartDate.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def activityStartDate
@activityStartDate
end
|
#activityStartTime ⇒ Object
Also known as:
start_time
Returns the value of attribute activityStartTime.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def activityStartTime
@activityStartTime
end
|
#assetDsc ⇒ Object
Returns the value of attribute assetDsc.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def assetDsc
@assetDsc
end
|
#assetGuid ⇒ Object
Also known as:
id
Returns the value of attribute assetGuid.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def assetGuid
@assetGuid
end
|
#assetName ⇒ Object
Also known as:
title
Returns the value of attribute assetName.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def assetName
@assetName
end
|
#authorName ⇒ Object
Also known as:
author_name
Returns the value of attribute authorName.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def authorName
@authorName
end
|
Returns the value of attribute contactEmailAdr.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def contactEmailAdr
@contactEmailAdr
end
|
Returns the value of attribute contactName.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def contactName
@contactName
end
|
Returns the value of attribute contactPhone.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def contactPhone
@contactPhone
end
|
Returns the value of attribute contactTxt.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def contactTxt
@contactTxt
end
|
#createdDate ⇒ Object
Also known as:
created_at
Returns the value of attribute createdDate.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def createdDate
@createdDate
end
|
#currencyCd ⇒ Object
Also known as:
currency_code
Returns the value of attribute currencyCd.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def currencyCd
@currencyCd
end
|
#homePageUrlAdr ⇒ Object
Also known as:
home_page_url
Returns the value of attribute homePageUrlAdr.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def homePageUrlAdr
@homePageUrlAdr
end
|
#is_article ⇒ Object
Returns the value of attribute is_article.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def is_article
@is_article
end
|
#is_event ⇒ Object
Returns the value of attribute is_event.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def is_event
@is_event
end
|
#isRecurring ⇒ Object
Also known as:
is_recurring?
Returns the value of attribute isRecurring.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def isRecurring
@isRecurring
end
|
#modifiedDate ⇒ Object
Also known as:
updated_at
Returns the value of attribute modifiedDate.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def modifiedDate
@modifiedDate
end
|
#publishDate ⇒ Object
Also known as:
published_at
Returns the value of attribute publishDate.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def publishDate
@publishDate
end
|
#regReqGenderCd ⇒ Object
Also known as:
required_gender
Returns the value of attribute regReqGenderCd.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def regReqGenderCd
@regReqGenderCd
end
|
#regReqMaxAge ⇒ Object
Also known as:
maximum_age
Returns the value of attribute regReqMaxAge.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def regReqMaxAge
@regReqMaxAge
end
|
#regReqMinAge ⇒ Object
Also known as:
minimum_age
Returns the value of attribute regReqMinAge.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def regReqMinAge
@regReqMinAge
end
|
Returns the value of attribute showContact.
23
24
25
|
# File 'lib/actv/asset.rb', line 23
def showContact
@showContact
end
|
Class Method Details
.from_response(response = {}) ⇒ Object
64
65
66
|
# File 'lib/actv/asset.rb', line 64
def self.from_response response={}
AssetFactory.new(response[:body]).asset
end
|
.inherited(base) ⇒ Object
56
57
58
|
# File 'lib/actv/asset.rb', line 56
def self.inherited base
@types << base
end
|
.types ⇒ Object
60
61
62
|
# File 'lib/actv/asset.rb', line 60
def self.types
@types + Array(self)
end
|
.valid?(response) ⇒ Boolean
Instance Method Details
#attribute_paths ⇒ Object
253
254
255
256
257
|
# File 'lib/actv/asset.rb', line 253
def attribute_paths
attributes.map do |attribute|
[sub_topic_path, urlize(attribute)].join "/"
end
end
|
#attributes ⇒ Object
245
246
247
248
249
250
251
|
# File 'lib/actv/asset.rb', line 245
def attributes
@attributes ||= assetAttributes.sort_by do |attribute|
attribute[:attribute][:attributeType]
end.map do |attribute|
attribute[:attribute][:attributeValue]
end
end
|
#category_is?(name) ⇒ Boolean
355
356
357
358
359
|
# File 'lib/actv/asset.rb', line 355
def category_is? name
@attrs[:assetCategories].any? do |cat|
cat[:category][:categoryName].downcase == name.downcase
end
end
|
#channels ⇒ Object
Also known as:
asset_channels, assetChannels
127
128
129
130
131
|
# File 'lib/actv/asset.rb', line 127
def channels
@asset_channels ||= Array(@attrs[:assetChannels]).map do |channel|
ACTV::AssetChannel.new(channel)
end
end
|
#components ⇒ Object
Also known as:
asset_components, assetComponents
152
153
154
155
156
|
# File 'lib/actv/asset.rb', line 152
def components
@asset_components ||= Array(@attrs[:assetComponents]).map do |component|
ACTV::AssetComponent.new(component)
end
end
|
#description ⇒ Object
193
194
195
|
# File 'lib/actv/asset.rb', line 193
def description
@description ||= description_by_type 'Standard'
end
|
#description_by_type(type) ⇒ Object
202
203
204
205
|
# File 'lib/actv/asset.rb', line 202
def description_by_type(type)
dsc = self.descriptions.find { |dsc| dsc.type.name.downcase == type.downcase }
(dsc.description.downcase == 'n/a' ? '' : dsc.description) if dsc
end
|
#descriptions ⇒ Object
Also known as:
asset_descriptions, assetDescriptions
102
103
104
105
106
107
|
# File 'lib/actv/asset.rb', line 102
def descriptions
@descriptions ||= Array(@attrs[:assetDescriptions]).map do |description|
description[:description] = convert_all_resource_to_https(description[:description])
ACTV::AssetDescription.new(description)
end
end
|
#endurance_id ⇒ Object
72
73
74
75
76
77
78
|
# File 'lib/actv/asset.rb', line 72
def endurance_id
if self.awendurance?
query_values = Addressable::URI.parse(registrationUrlAdr.to_s).query_values
query_values ||= {}
query_values.fetch 'e', nil
end
end
|
#evergreen? ⇒ Boolean
232
233
234
|
# File 'lib/actv/asset.rb', line 232
def evergreen?
self.evergreenAssetFlag.downcase == 'true' rescue false
end
|
#first_topic ⇒ Object
Also known as:
topic
277
278
279
|
# File 'lib/actv/asset.rb', line 277
def first_topic
get_first_topic_taxonomy[0]
end
|
#first_topic_name ⇒ Object
286
287
288
|
# File 'lib/actv/asset.rb', line 286
def first_topic_name
topics.first.topic.name unless topics.empty?
end
|
#first_topic_path ⇒ Object
282
283
284
|
# File 'lib/actv/asset.rb', line 282
def first_topic_path
urlize first_topic
end
|
#has_location? ⇒ Boolean
228
229
230
|
# File 'lib/actv/asset.rb', line 228
def has_location?
self.place && place.has_lat_long?
end
|
#has_volume_based_price? ⇒ Boolean
168
169
170
|
# File 'lib/actv/asset.rb', line 168
def has_volume_based_price?
prices.any? { |price| price.volume_pricing? }
end
|
#image ⇒ Object
345
346
347
|
# File 'lib/actv/asset.rb', line 345
def image
image_without_placeholder
end
|
#image_by_name(name) ⇒ Object
207
208
209
|
# File 'lib/actv/asset.rb', line 207
def image_by_name(name)
self.images.find { |img| img.name.downcase == name.downcase }
end
|
#image_path ⇒ Object
330
331
332
333
334
335
336
337
338
339
|
# File 'lib/actv/asset.rb', line 330
def image_path
default_image = 'https://www.active.com/images/events/hotrace.gif'
image = image_without_placeholder.imageUrlAdr rescue ""
if image.empty? and (logoUrlAdr && logoUrlAdr != default_image && !(logoUrlAdr =~ URI::regexp).nil?)
image = logoUrlAdr
end
image
end
|
#image_with_placeholder ⇒ Object
322
323
324
325
326
327
328
|
# File 'lib/actv/asset.rb', line 322
def image_with_placeholder
if image_path.empty?
"/images/logo-active-icon-gray.gif"
else
image_path
end
end
|
#images ⇒ Object
Also known as:
asset_images, assetImages
135
136
137
138
139
140
|
# File 'lib/actv/asset.rb', line 135
def images
@images ||= Array(@attrs[:assetImages]).map do |img|
img[:imageUrlAdr] = replace_http_to_https(img[:imageUrlAdr]) unless 'MediaGalleryButton' == img[:imageName]
ACTV::AssetImage.new(img)
end
end
|
#is_article? ⇒ Boolean
220
221
222
|
# File 'lib/actv/asset.rb', line 220
def is_article?
false
end
|
#is_event? ⇒ Boolean
216
217
218
|
# File 'lib/actv/asset.rb', line 216
def is_event?
false
end
|
#is_video? ⇒ Boolean
224
225
226
|
# File 'lib/actv/asset.rb', line 224
def is_video?
false
end
|
#kids? ⇒ Boolean
236
237
238
|
# File 'lib/actv/asset.rb', line 236
def kids?
kids_friendly_source_system? && kids_interest?
end
|
#legacy_data ⇒ Object
Also known as:
asset_legacy_data, assetLegacyData
121
122
123
|
# File 'lib/actv/asset.rb', line 121
def legacy_data
@legacy_data ||= ACTV::AssetLegacyData.new(@attrs[:assetLegacyData]) unless @attrs[:assetLegacyData].nil?
end
|
#location_path ⇒ Object
273
274
275
|
# File 'lib/actv/asset.rb', line 273
def location_path
@location ||= "#{place.cityName} #{place.stateProvinceCode}".downcase.gsub ' ','-'
end
|
341
342
343
|
# File 'lib/actv/asset.rb', line 341
def media_url
image_without_placeholder.imageUrlAdr rescue ""
end
|
267
268
269
270
271
|
# File 'lib/actv/asset.rb', line 267
def meta_interest_paths
meta_interests.map do |meta_interest|
[sub_topic_path, urlize(meta_interest)].join "/"
end
end
|
259
260
261
262
263
264
265
|
# File 'lib/actv/asset.rb', line 259
def meta_interests
@meta_interests ||= attrs[:assetMetaInterests].sort_by do |interest|
interest[:sequence]
end.map do |interest|
interest[:metaInterest][:metaInterestName]
end
end
|
#org_timezone ⇒ Object
94
95
96
|
# File 'lib/actv/asset.rb', line 94
def org_timezone
@org_timezone ||= @attrs[:localTimeZoneId] unless @attrs[:localTimeZoneId].nil?
end
|
#organization ⇒ Object
361
362
363
|
# File 'lib/actv/asset.rb', line 361
def organization
@attrs[:organization] || {}
end
|
#place ⇒ Object
86
87
88
|
# File 'lib/actv/asset.rb', line 86
def place
@place ||= ACTV::Place.new(@attrs[:place]) unless @attrs[:place].nil?
end
|
#place_timezone ⇒ Object
90
91
92
|
# File 'lib/actv/asset.rb', line 90
def place_timezone
@place_timezone ||= place[:timezone] unless place[:timezone].nil?
end
|
#prices ⇒ Object
Also known as:
asset_prices, assetPrices
160
161
162
163
164
|
# File 'lib/actv/asset.rb', line 160
def prices
@asset_prices ||= Array(@attrs[:assetPrices]).map do |price|
ACTV::AssetPrice.new(price)
end
end
|
#recurrences ⇒ Object
80
81
82
83
84
|
# File 'lib/actv/asset.rb', line 80
def recurrences
@recurrences ||= Array(@attrs[:activityRecurrences]).map do | recurrence |
ACTV::Recurrence.new(recurrence)
end
end
|
#references ⇒ Object
349
350
351
352
353
|
# File 'lib/actv/asset.rb', line 349
def references
@references ||= Array(@attrs[:assetReferences]).map do |reference|
ACTV::AssetReference.new reference
end
end
|
#registration_status ⇒ Object
Also known as:
reg_status
240
241
242
|
# File 'lib/actv/asset.rb', line 240
def registration_status
@registration_status ||= nil
end
|
#seo_url(systemName = 'as3') ⇒ Object
197
198
199
200
|
# File 'lib/actv/asset.rb', line 197
def seo_url(systemName = 'as3')
seo_url = self.seo_urls.find { |s| s.seoSystemName.downcase == systemName.downcase }
seo_url.urlAdr unless seo_url.nil?
end
|
#seo_urls ⇒ Object
Also known as:
asset_seo_urls, assetSeoUrls
180
181
182
183
184
185
|
# File 'lib/actv/asset.rb', line 180
def seo_urls
@seo_urls ||= Array(@attrs[:assetSeoUrls]).map do |seo_url|
seo_url[:urlAdr] = replace_http_to_https seo_url[:urlAdr]
ACTV::AssetSeoUrl.new(seo_url)
end
end
|
365
366
367
|
# File 'lib/actv/asset.rb', line 365
def
.present? && [:enabled].to_s == 'true' &&
end
|
#status ⇒ Object
Also known as:
asset_status, assetStatus
111
112
113
|
# File 'lib/actv/asset.rb', line 111
def status
@status ||= ACTV::AssetStatus.new(@attrs[:assetStatus]) unless @attrs[:assetStatus].nil?
end
|
#sub_2_topic ⇒ Object
298
299
300
|
# File 'lib/actv/asset.rb', line 298
def sub_2_topic
get_first_topic_taxonomy[2]
end
|
#sub_2_topic_path ⇒ Object
302
303
304
|
# File 'lib/actv/asset.rb', line 302
def sub_2_topic_path
urlize "#{sub_topic_path}/#{sub_2_topic}"
end
|
#sub_3_topic ⇒ Object
306
307
308
|
# File 'lib/actv/asset.rb', line 306
def sub_3_topic
get_first_topic_taxonomy[3]
end
|
#sub_3_topic_path ⇒ Object
310
311
312
|
# File 'lib/actv/asset.rb', line 310
def sub_3_topic_path
urlize "#{sub_2_topic_path}/#{sub_3_topic}"
end
|
#sub_4_topic ⇒ Object
314
315
316
|
# File 'lib/actv/asset.rb', line 314
def sub_4_topic
get_first_topic_taxonomy[4]
end
|
#sub_4_topic_path ⇒ Object
318
319
320
|
# File 'lib/actv/asset.rb', line 318
def sub_4_topic_path
urlize "#{sub_3_topic_path}/#{sub_4_topic}"
end
|
#sub_topic ⇒ Object
290
291
292
|
# File 'lib/actv/asset.rb', line 290
def sub_topic
get_first_topic_taxonomy[1]
end
|
#sub_topic_path ⇒ Object
294
295
296
|
# File 'lib/actv/asset.rb', line 294
def sub_topic_path
urlize sub_topic
end
|
#summary ⇒ Object
189
190
191
|
# File 'lib/actv/asset.rb', line 189
def summary
@summary ||= description_by_type 'summary'
end
|
#tag_by_description(description) ⇒ Object
211
212
213
214
|
# File 'lib/actv/asset.rb', line 211
def tag_by_description(description)
asset_tag = self.tags.find { |at| at.tag.description.downcase == description.downcase }
asset_tag.tag.name if asset_tag
end
|
144
145
146
147
148
|
# File 'lib/actv/asset.rb', line 144
def tags
@asset_tags ||= Array(@attrs[:assetTags]).map do |tag|
ACTV::AssetTag.new(tag)
end
end
|
#topics ⇒ Object
Also known as:
asset_topics, assetTopics
172
173
174
175
176
|
# File 'lib/actv/asset.rb', line 172
def topics
@asset_topics ||= Array(@attrs[:assetTopics]).map do |topic|
ACTV::AssetTopic.new(topic)
end.sort
end
|
#version ⇒ Object
98
99
100
|
# File 'lib/actv/asset.rb', line 98
def version
@asset_version ||= @attrs[:assetVersion] unless @attrs[:assetVersion].nil?
end
|
#visible? ⇒ Boolean
117
118
119
|
# File 'lib/actv/asset.rb', line 117
def visible?
asset_status.visible?
end
|