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)
-
#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
#==, #initialize
Methods inherited from Base
#[], attr_reader, define_attribute_method, define_predicate_method, define_uri_method, #delete, #initialize, #memoize, #method_missing, object_attr_reader, #respond_to?, #to_hash, #update, uri_attr_reader
Constructor Details
This class inherits a constructor from ACTV::Identity
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
59
60
61
|
# File 'lib/actv/asset.rb', line 59
def self.from_response response={}
AssetFactory.new(response[:body]).asset
end
|
.inherited(base) ⇒ Object
51
52
53
|
# File 'lib/actv/asset.rb', line 51
def self.inherited base
@types << base
end
|
.types ⇒ Object
55
56
57
|
# File 'lib/actv/asset.rb', line 55
def self.types
@types + Array(self)
end
|
.valid?(response) ⇒ Boolean
Instance Method Details
#attribute_paths ⇒ Object
245
246
247
248
249
|
# File 'lib/actv/asset.rb', line 245
def attribute_paths
attributes.map do |attribute|
[sub_topic_path, urlize(attribute)].join "/"
end
end
|
#attributes ⇒ Object
237
238
239
240
241
242
243
|
# File 'lib/actv/asset.rb', line 237
def attributes
@attributes ||= assetAttributes.sort_by do |attribute|
attribute[:attribute][:attributeType]
end.map do |attribute|
attribute[:attribute][:attributeValue]
end
end
|
#category_is?(name) ⇒ Boolean
347
348
349
350
351
|
# File 'lib/actv/asset.rb', line 347
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
121
122
123
124
125
|
# File 'lib/actv/asset.rb', line 121
def channels
@asset_channels ||= Array(@attrs[:assetChannels]).map do |channel|
ACTV::AssetChannel.new(channel)
end
end
|
#components ⇒ Object
Also known as:
asset_components, assetComponents
145
146
147
148
149
|
# File 'lib/actv/asset.rb', line 145
def components
@asset_components ||= Array(@attrs[:assetComponents]).map do |component|
ACTV::AssetComponent.new(component)
end
end
|
#description ⇒ Object
185
186
187
|
# File 'lib/actv/asset.rb', line 185
def description
@description ||= description_by_type 'Standard'
end
|
#description_by_type(type) ⇒ Object
194
195
196
197
|
# File 'lib/actv/asset.rb', line 194
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
97
98
99
100
101
|
# File 'lib/actv/asset.rb', line 97
def descriptions
@descriptions ||= Array(@attrs[:assetDescriptions]).map do |description|
ACTV::AssetDescription.new(description)
end
end
|
#endurance_id ⇒ Object
67
68
69
70
71
72
73
|
# File 'lib/actv/asset.rb', line 67
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
224
225
226
|
# File 'lib/actv/asset.rb', line 224
def evergreen?
self.evergreenAssetFlag.downcase == 'true' rescue false
end
|
#first_topic ⇒ Object
Also known as:
topic
269
270
271
|
# File 'lib/actv/asset.rb', line 269
def first_topic
get_first_topic_taxonomy[0]
end
|
#first_topic_name ⇒ Object
278
279
280
|
# File 'lib/actv/asset.rb', line 278
def first_topic_name
topics.first.topic.name unless topics.empty?
end
|
#first_topic_path ⇒ Object
274
275
276
|
# File 'lib/actv/asset.rb', line 274
def first_topic_path
urlize first_topic
end
|
#has_location? ⇒ Boolean
220
221
222
|
# File 'lib/actv/asset.rb', line 220
def has_location?
self.place && place.has_lat_long?
end
|
#has_volume_based_price? ⇒ Boolean
161
162
163
|
# File 'lib/actv/asset.rb', line 161
def has_volume_based_price?
prices.any? { |price| price.volume_pricing? }
end
|
#image ⇒ Object
337
338
339
|
# File 'lib/actv/asset.rb', line 337
def image
image_without_placeholder
end
|
#image_by_name(name) ⇒ Object
199
200
201
|
# File 'lib/actv/asset.rb', line 199
def image_by_name(name)
self.images.find { |img| img.name.downcase == name.downcase }
end
|
#image_path ⇒ Object
322
323
324
325
326
327
328
329
330
331
|
# File 'lib/actv/asset.rb', line 322
def image_path
default_image = 'http://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
314
315
316
317
318
319
320
|
# File 'lib/actv/asset.rb', line 314
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
129
130
131
132
133
|
# File 'lib/actv/asset.rb', line 129
def images
@images ||= Array(@attrs[:assetImages]).map do |img|
ACTV::AssetImage.new(img)
end
end
|
#is_article? ⇒ Boolean
212
213
214
|
# File 'lib/actv/asset.rb', line 212
def is_article?
false
end
|
#is_event? ⇒ Boolean
208
209
210
|
# File 'lib/actv/asset.rb', line 208
def is_event?
false
end
|
#is_video? ⇒ Boolean
216
217
218
|
# File 'lib/actv/asset.rb', line 216
def is_video?
false
end
|
#kids? ⇒ Boolean
228
229
230
|
# File 'lib/actv/asset.rb', line 228
def kids?
kids_friendly_source_system? && kids_interest?
end
|
#legacy_data ⇒ Object
Also known as:
asset_legacy_data, assetLegacyData
115
116
117
|
# File 'lib/actv/asset.rb', line 115
def legacy_data
@legacy_data ||= ACTV::AssetLegacyData.new(@attrs[:assetLegacyData]) unless @attrs[:assetLegacyData].nil?
end
|
#location_path ⇒ Object
265
266
267
|
# File 'lib/actv/asset.rb', line 265
def location_path
@location ||= "#{place.cityName} #{place.stateProvinceCode}".downcase.gsub ' ','-'
end
|
333
334
335
|
# File 'lib/actv/asset.rb', line 333
def media_url
image_without_placeholder.imageUrlAdr rescue ""
end
|
259
260
261
262
263
|
# File 'lib/actv/asset.rb', line 259
def meta_interest_paths
meta_interests.map do |meta_interest|
[sub_topic_path, urlize(meta_interest)].join "/"
end
end
|
251
252
253
254
255
256
257
|
# File 'lib/actv/asset.rb', line 251
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
89
90
91
|
# File 'lib/actv/asset.rb', line 89
def org_timezone
@org_timezone ||= @attrs[:localTimeZoneId] unless @attrs[:localTimeZoneId].nil?
end
|
#organization ⇒ Object
353
354
355
|
# File 'lib/actv/asset.rb', line 353
def organization
@attrs[:organization] || {}
end
|
#place ⇒ Object
81
82
83
|
# File 'lib/actv/asset.rb', line 81
def place
@place ||= ACTV::Place.new(@attrs[:place]) unless @attrs[:place].nil?
end
|
#place_timezone ⇒ Object
85
86
87
|
# File 'lib/actv/asset.rb', line 85
def place_timezone
@place_timezone ||= place[:timezone] unless place[:timezone].nil?
end
|
#prices ⇒ Object
Also known as:
asset_prices, assetPrices
153
154
155
156
157
|
# File 'lib/actv/asset.rb', line 153
def prices
@asset_prices ||= Array(@attrs[:assetPrices]).map do |price|
ACTV::AssetPrice.new(price)
end
end
|
#recurrences ⇒ Object
75
76
77
78
79
|
# File 'lib/actv/asset.rb', line 75
def recurrences
@recurrences ||= Array(@attrs[:activityRecurrences]).map do | recurrence |
ACTV::Recurrence.new(recurrence)
end
end
|
#references ⇒ Object
341
342
343
344
345
|
# File 'lib/actv/asset.rb', line 341
def references
@references ||= Array(@attrs[:assetReferences]).map do |reference|
ACTV::AssetReference.new reference
end
end
|
#registration_status ⇒ Object
Also known as:
reg_status
232
233
234
|
# File 'lib/actv/asset.rb', line 232
def registration_status
@registration_status ||= nil
end
|
#seo_url(systemName = 'as3') ⇒ Object
189
190
191
192
|
# File 'lib/actv/asset.rb', line 189
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
173
174
175
176
177
|
# File 'lib/actv/asset.rb', line 173
def seo_urls
@seo_urls ||= Array(@attrs[:assetSeoUrls]).map do |seo_url|
ACTV::AssetSeoUrl.new(seo_url)
end
end
|
357
358
359
|
# File 'lib/actv/asset.rb', line 357
def
.present? && [:enabled].to_s == 'true' &&
end
|
#status ⇒ Object
Also known as:
asset_status, assetStatus
105
106
107
|
# File 'lib/actv/asset.rb', line 105
def status
@status ||= ACTV::AssetStatus.new(@attrs[:assetStatus]) unless @attrs[:assetStatus].nil?
end
|
#sub_2_topic ⇒ Object
290
291
292
|
# File 'lib/actv/asset.rb', line 290
def sub_2_topic
get_first_topic_taxonomy[2]
end
|
#sub_2_topic_path ⇒ Object
294
295
296
|
# File 'lib/actv/asset.rb', line 294
def sub_2_topic_path
urlize "#{sub_topic_path}/#{sub_2_topic}"
end
|
#sub_3_topic ⇒ Object
298
299
300
|
# File 'lib/actv/asset.rb', line 298
def sub_3_topic
get_first_topic_taxonomy[3]
end
|
#sub_3_topic_path ⇒ Object
302
303
304
|
# File 'lib/actv/asset.rb', line 302
def sub_3_topic_path
urlize "#{sub_2_topic_path}/#{sub_3_topic}"
end
|
#sub_4_topic ⇒ Object
306
307
308
|
# File 'lib/actv/asset.rb', line 306
def sub_4_topic
get_first_topic_taxonomy[4]
end
|
#sub_4_topic_path ⇒ Object
310
311
312
|
# File 'lib/actv/asset.rb', line 310
def sub_4_topic_path
urlize "#{sub_3_topic_path}/#{sub_4_topic}"
end
|
#sub_topic ⇒ Object
282
283
284
|
# File 'lib/actv/asset.rb', line 282
def sub_topic
get_first_topic_taxonomy[1]
end
|
#sub_topic_path ⇒ Object
286
287
288
|
# File 'lib/actv/asset.rb', line 286
def sub_topic_path
urlize sub_topic
end
|
#summary ⇒ Object
181
182
183
|
# File 'lib/actv/asset.rb', line 181
def summary
@summary ||= description_by_type 'summary'
end
|
#tag_by_description(description) ⇒ Object
203
204
205
206
|
# File 'lib/actv/asset.rb', line 203
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
|
137
138
139
140
141
|
# File 'lib/actv/asset.rb', line 137
def tags
@asset_tags ||= Array(@attrs[:assetTags]).map do |tag|
ACTV::AssetTag.new(tag)
end
end
|
#topics ⇒ Object
Also known as:
asset_topics, assetTopics
165
166
167
168
169
|
# File 'lib/actv/asset.rb', line 165
def topics
@asset_topics ||= Array(@attrs[:assetTopics]).map do |topic|
ACTV::AssetTopic.new(topic)
end.sort
end
|
#version ⇒ Object
93
94
95
|
# File 'lib/actv/asset.rb', line 93
def version
@asset_version ||= @attrs[:assetVersion] unless @attrs[:assetVersion].nil?
end
|
#visible? ⇒ Boolean
111
112
113
|
# File 'lib/actv/asset.rb', line 111
def visible?
asset_status.visible?
end
|