Class: ACTV::Asset
Instance Attribute Summary collapse
Attributes inherited from Base
#attrs
Instance Method Summary
collapse
-
#activenet? ⇒ Boolean
-
#attribute_paths ⇒ Object
-
#attributes ⇒ Object
-
#awcamps30? ⇒ Boolean
-
#awcamps? ⇒ Boolean
-
#awendurance? ⇒ Boolean
-
#awsports? ⇒ 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
-
#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
-
#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
-
#place ⇒ Object
-
#place_timezone ⇒ Object
-
#prices ⇒ Object
(also: #asset_prices, #assetPrices)
-
#recurrences ⇒ Object
-
#regcenter2? ⇒ Boolean
-
#regcenter? ⇒ Boolean
-
#registration_status ⇒ Object
(also: #reg_status)
-
#seo_url(systemName = 'as3') ⇒ Object
-
#seo_urls ⇒ Object
(also: #asset_seo_urls, #assetSeoUrls)
-
#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)
-
#thriva? ⇒ Boolean
-
#topics ⇒ Object
(also: #asset_topics, #assetTopics)
-
#version ⇒ Object
-
#visible? ⇒ Boolean
Methods inherited from Identity
#==, #initialize
Methods inherited from Base
#[], attr_reader, define_attribute_method, define_predicate_method, define_uri_method, from_response, #initialize, #memoize, #method_missing, object_attr_reader, #respond_to?, #to_hash, 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.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def activityEndDate
@activityEndDate
end
|
#activityEndTime ⇒ Object
Also known as:
end_time
Returns the value of attribute activityEndTime.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def activityEndTime
@activityEndTime
end
|
#activityStartDate ⇒ Object
Also known as:
start_date, activity_start_date
Returns the value of attribute activityStartDate.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def activityStartDate
@activityStartDate
end
|
#activityStartTime ⇒ Object
Also known as:
start_time
Returns the value of attribute activityStartTime.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def activityStartTime
@activityStartTime
end
|
#assetDsc ⇒ Object
Returns the value of attribute assetDsc.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def assetDsc
@assetDsc
end
|
#assetGuid ⇒ Object
Also known as:
id
Returns the value of attribute assetGuid.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def assetGuid
@assetGuid
end
|
#assetName ⇒ Object
Also known as:
title
Returns the value of attribute assetName.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def assetName
@assetName
end
|
#authorName ⇒ Object
Also known as:
author_name
Returns the value of attribute authorName.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def authorName
@authorName
end
|
Returns the value of attribute contactEmailAdr.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def contactEmailAdr
@contactEmailAdr
end
|
Returns the value of attribute contactName.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def contactName
@contactName
end
|
Returns the value of attribute contactPhone.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def contactPhone
@contactPhone
end
|
Returns the value of attribute contactTxt.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def contactTxt
@contactTxt
end
|
#createdDate ⇒ Object
Also known as:
created_at
Returns the value of attribute createdDate.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def createdDate
@createdDate
end
|
#currencyCd ⇒ Object
Also known as:
currency_code
Returns the value of attribute currencyCd.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def currencyCd
@currencyCd
end
|
#homePageUrlAdr ⇒ Object
Also known as:
home_page_url
Returns the value of attribute homePageUrlAdr.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def homePageUrlAdr
@homePageUrlAdr
end
|
#is_article ⇒ Object
Returns the value of attribute is_article.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def is_article
@is_article
end
|
#is_event ⇒ Object
Returns the value of attribute is_event.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def is_event
@is_event
end
|
#isRecurring ⇒ Object
Also known as:
is_recurring?
Returns the value of attribute isRecurring.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def isRecurring
@isRecurring
end
|
#modifiedDate ⇒ Object
Also known as:
updated_at
Returns the value of attribute modifiedDate.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def modifiedDate
@modifiedDate
end
|
#publishDate ⇒ Object
Also known as:
published_at
Returns the value of attribute publishDate.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def publishDate
@publishDate
end
|
#regReqGenderCd ⇒ Object
Also known as:
required_gender
Returns the value of attribute regReqGenderCd.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def regReqGenderCd
@regReqGenderCd
end
|
#regReqMaxAge ⇒ Object
Also known as:
maximum_age
Returns the value of attribute regReqMaxAge.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def regReqMaxAge
@regReqMaxAge
end
|
#regReqMinAge ⇒ Object
Also known as:
minimum_age
Returns the value of attribute regReqMinAge.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def regReqMinAge
@regReqMinAge
end
|
Returns the value of attribute showContact.
18
19
20
|
# File 'lib/actv/asset.rb', line 18
def showContact
@showContact
end
|
Instance Method Details
#activenet? ⇒ Boolean
242
243
244
|
# File 'lib/actv/asset.rb', line 242
def activenet?
self.sourceSystem[:legacyGuid].upcase == "FB27C928-54DB-4ECD-B42F-482FC3C8681F" rescue false
end
|
#attribute_paths ⇒ Object
264
265
266
267
268
|
# File 'lib/actv/asset.rb', line 264
def attribute_paths
attributes.map do |attribute|
[sub_topic_path, urlize(attribute)].join "/"
end
end
|
#attributes ⇒ Object
256
257
258
259
260
261
262
|
# File 'lib/actv/asset.rb', line 256
def attributes
@attributes ||= assetAttributes.sort_by do |attribute|
attribute[:attribute][:attributeType]
end.map do |attribute|
attribute[:attribute][:attributeValue]
end
end
|
#awcamps30? ⇒ Boolean
234
235
236
|
# File 'lib/actv/asset.rb', line 234
def awcamps30?
self.sourceSystem[:legacyGuid].upcase == "89208DBA-F535-4950-880A-34A6888A184C" rescue false
end
|
#awcamps? ⇒ Boolean
230
231
232
|
# File 'lib/actv/asset.rb', line 230
def awcamps?
self.sourceSystem[:legacyGuid].upcase == "2B22B4E6-5AA4-44D7-BF06-F7A71F9FA8A6" rescue false
end
|
#awendurance? ⇒ Boolean
222
223
224
|
# File 'lib/actv/asset.rb', line 222
def awendurance?
self.sourceSystem[:legacyGuid].upcase == "DFAA997A-D591-44CA-9FB7-BF4A4C8984F1" rescue false
end
|
#awsports? ⇒ Boolean
226
227
228
|
# File 'lib/actv/asset.rb', line 226
def awsports?
self.sourceSystem[:legacyGuid].upcase == "F036B0FF-2B21-43A9-8C20-7F447D3AB105" rescue false
end
|
#channels ⇒ Object
Also known as:
asset_channels, assetChannels
98
99
100
101
102
|
# File 'lib/actv/asset.rb', line 98
def channels
@asset_channels ||= Array(@attrs[:assetChannels]).map do |channel|
ACTV::AssetChannel.new(channel)
end
end
|
#components ⇒ Object
Also known as:
asset_components, assetComponents
122
123
124
125
126
|
# File 'lib/actv/asset.rb', line 122
def components
@asset_components ||= Array(@attrs[:assetComponents]).map do |component|
ACTV::AssetComponent.new(component)
end
end
|
#description ⇒ Object
158
159
160
|
# File 'lib/actv/asset.rb', line 158
def description
@description ||= description_by_type 'Standard'
end
|
#description_by_type(type) ⇒ Object
167
168
169
170
|
# File 'lib/actv/asset.rb', line 167
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
74
75
76
77
78
|
# File 'lib/actv/asset.rb', line 74
def descriptions
@descriptions ||= Array(@attrs[:assetDescriptions]).map do |description|
ACTV::AssetDescription.new(description)
end
end
|
#endurance_id ⇒ Object
46
47
48
49
50
|
# File 'lib/actv/asset.rb', line 46
def endurance_id
if self.awendurance?
Addressable::URI.parse(registrationUrlAdr.to_s).query_values.to_h.fetch 'e', nil
end
end
|
#evergreen? ⇒ Boolean
210
211
212
|
# File 'lib/actv/asset.rb', line 210
def evergreen?
self.evergreenAssetFlag.downcase == 'true' rescue false
end
|
#first_topic ⇒ Object
Also known as:
topic
288
289
290
|
# File 'lib/actv/asset.rb', line 288
def first_topic
get_first_topic_taxonomy[0]
end
|
#first_topic_name ⇒ Object
297
298
299
|
# File 'lib/actv/asset.rb', line 297
def first_topic_name
topics.first.topic.name
end
|
#first_topic_path ⇒ Object
293
294
295
|
# File 'lib/actv/asset.rb', line 293
def first_topic_path
urlize first_topic
end
|
#has_location? ⇒ Boolean
206
207
208
|
# File 'lib/actv/asset.rb', line 206
def has_location?
self.place && place.has_lat_long?
end
|
#image ⇒ Object
356
357
358
|
# File 'lib/actv/asset.rb', line 356
def image
image_without_placeholder
end
|
#image_by_name(name) ⇒ Object
172
173
174
|
# File 'lib/actv/asset.rb', line 172
def image_by_name(name)
self.images.find { |img| img.name.downcase == name.downcase }
end
|
#image_path ⇒ Object
341
342
343
344
345
346
347
348
349
350
|
# File 'lib/actv/asset.rb', line 341
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
333
334
335
336
337
338
339
|
# File 'lib/actv/asset.rb', line 333
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
106
107
108
109
110
|
# File 'lib/actv/asset.rb', line 106
def images
@images ||= Array(@attrs[:assetImages]).map do |img|
ACTV::AssetImage.new(img)
end
end
|
#is_article? ⇒ Boolean
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
# File 'lib/actv/asset.rb', line 190
def is_article?
is_article = false
if self.assetCategories.any?
self.assetCategories.each do |category|
if category[:category][:categoryName].downcase == 'articles'
is_article = true
end
end
else
is_article = articles_source?
end
is_article
end
|
#is_event? ⇒ Boolean
181
182
183
184
185
186
187
188
|
# File 'lib/actv/asset.rb', line 181
def is_event?
self.assetCategories.each do |category|
if category[:category][:categoryTaxonomy].downcase.start_with?('event')
return true
end
end
false
end
|
#kids? ⇒ Boolean
246
247
248
249
|
# File 'lib/actv/asset.rb', line 246
def kids?
return false if Rails.env == 'production'
kids_friendly_source_system? && kids_interest?
end
|
#legacy_data ⇒ Object
Also known as:
asset_legacy_data, assetLegacyData
92
93
94
|
# File 'lib/actv/asset.rb', line 92
def legacy_data
@legacy_data ||= ACTV::AssetLegacyData.new(@attrs[:assetLegacyData]) unless @attrs[:assetLegacyData].nil?
end
|
#location_path ⇒ Object
284
285
286
|
# File 'lib/actv/asset.rb', line 284
def location_path
@location ||= "#{place.cityName} #{place.stateProvinceCode}".downcase.gsub ' ','-'
end
|
352
353
354
|
# File 'lib/actv/asset.rb', line 352
def media_url
image_without_placeholder.imageUrlAdr rescue ""
end
|
278
279
280
281
282
|
# File 'lib/actv/asset.rb', line 278
def meta_interest_paths
meta_interests.map do |meta_interest|
[sub_topic_path, urlize(meta_interest)].join "/"
end
end
|
270
271
272
273
274
275
276
|
# File 'lib/actv/asset.rb', line 270
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
66
67
68
|
# File 'lib/actv/asset.rb', line 66
def org_timezone
@org_timezone ||= @attrs[:localTimeZoneId] unless @attrs[:localTimeZoneId].nil?
end
|
#place ⇒ Object
58
59
60
|
# File 'lib/actv/asset.rb', line 58
def place
@place ||= ACTV::Place.new(@attrs[:place]) unless @attrs[:place].nil?
end
|
#place_timezone ⇒ Object
62
63
64
|
# File 'lib/actv/asset.rb', line 62
def place_timezone
@place_timezone ||= place[:timezone] unless place[:timezone].nil?
end
|
#prices ⇒ Object
Also known as:
asset_prices, assetPrices
130
131
132
133
134
|
# File 'lib/actv/asset.rb', line 130
def prices
@asset_prices ||= Array(@attrs[:assetPrices]).map do |price|
ACTV::AssetPrice.new(price)
end
end
|
#recurrences ⇒ Object
52
53
54
55
56
|
# File 'lib/actv/asset.rb', line 52
def recurrences
@recurrences ||= Array(@attrs[:activityRecurrences]).map do | recurrence |
ACTV::Recurrence.new(recurrence)
end
end
|
#regcenter2? ⇒ Boolean
218
219
220
|
# File 'lib/actv/asset.rb', line 218
def regcenter2?
self.sourceSystem[:legacyGuid].upcase == "3BF82BBE-CF88-4E8C-A56F-78F5CE87E4C6" rescue false
end
|
#regcenter? ⇒ Boolean
214
215
216
|
# File 'lib/actv/asset.rb', line 214
def regcenter?
self.sourceSystem[:legacyGuid].upcase == "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65" rescue false
end
|
#registration_status ⇒ Object
Also known as:
reg_status
251
252
253
|
# File 'lib/actv/asset.rb', line 251
def registration_status
@registration_status ||= nil
end
|
#seo_url(systemName = 'as3') ⇒ Object
162
163
164
165
|
# File 'lib/actv/asset.rb', line 162
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
146
147
148
149
150
|
# File 'lib/actv/asset.rb', line 146
def seo_urls
@seo_urls ||= Array(@attrs[:assetSeoUrls]).map do |seo_url|
ACTV::AssetSeoUrl.new(seo_url)
end
end
|
#status ⇒ Object
Also known as:
asset_status, assetStatus
82
83
84
|
# File 'lib/actv/asset.rb', line 82
def status
@status ||= ACTV::AssetStatus.new(@attrs[:assetStatus]) unless @attrs[:assetStatus].nil?
end
|
#sub_2_topic ⇒ Object
309
310
311
|
# File 'lib/actv/asset.rb', line 309
def sub_2_topic
get_first_topic_taxonomy[2]
end
|
#sub_2_topic_path ⇒ Object
313
314
315
|
# File 'lib/actv/asset.rb', line 313
def sub_2_topic_path
urlize "#{sub_topic_path}/#{sub_2_topic}"
end
|
#sub_3_topic ⇒ Object
317
318
319
|
# File 'lib/actv/asset.rb', line 317
def sub_3_topic
get_first_topic_taxonomy[3]
end
|
#sub_3_topic_path ⇒ Object
321
322
323
|
# File 'lib/actv/asset.rb', line 321
def sub_3_topic_path
urlize "#{sub_2_topic_path}/#{sub_3_topic}"
end
|
#sub_4_topic ⇒ Object
325
326
327
|
# File 'lib/actv/asset.rb', line 325
def sub_4_topic
get_first_topic_taxonomy[4]
end
|
#sub_4_topic_path ⇒ Object
329
330
331
|
# File 'lib/actv/asset.rb', line 329
def sub_4_topic_path
urlize "#{sub_3_topic_path}/#{sub_4_topic}"
end
|
#sub_topic ⇒ Object
301
302
303
|
# File 'lib/actv/asset.rb', line 301
def sub_topic
get_first_topic_taxonomy[1]
end
|
#sub_topic_path ⇒ Object
305
306
307
|
# File 'lib/actv/asset.rb', line 305
def sub_topic_path
urlize sub_topic
end
|
#summary ⇒ Object
154
155
156
|
# File 'lib/actv/asset.rb', line 154
def summary
@summary ||= description_by_type 'summary'
end
|
#tag_by_description(description) ⇒ Object
176
177
178
179
|
# File 'lib/actv/asset.rb', line 176
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
|
114
115
116
117
118
|
# File 'lib/actv/asset.rb', line 114
def tags
@asset_tags ||= Array(@attrs[:assetTags]).map do |tag|
ACTV::AssetTag.new(tag)
end
end
|
#thriva? ⇒ Boolean
238
239
240
|
# File 'lib/actv/asset.rb', line 238
def thriva?
self.sourceSystem[:legacyGuid].upcase == "2BA50ABA-080E-4E3D-A01C-1B4F56648A2E" rescue false
end
|
#topics ⇒ Object
Also known as:
asset_topics, assetTopics
138
139
140
141
142
|
# File 'lib/actv/asset.rb', line 138
def topics
@asset_topics ||= Array(@attrs[:assetTopics]).map do |topic|
ACTV::AssetTopic.new(topic)
end.sort
end
|
#version ⇒ Object
70
71
72
|
# File 'lib/actv/asset.rb', line 70
def version
@asset_version ||= @attrs[:assetVersion] unless @attrs[:assetVersion].nil?
end
|
#visible? ⇒ Boolean
88
89
90
|
# File 'lib/actv/asset.rb', line 88
def visible?
asset_status.visible?
end
|