Class: ACTV::Asset

Inherits:
Identity show all
Defined in:
lib/actv/asset.rb

Direct Known Subclasses

Article, Event

Instance Attribute Summary collapse

Attributes inherited from Base

#attrs

Instance Method Summary collapse

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

#activityEndDateObject (readonly) Also known as: end_date

Returns the value of attribute activityEndDate.



17
18
19
# File 'lib/actv/asset.rb', line 17

def activityEndDate
  @activityEndDate
end

#activityEndTimeObject (readonly) Also known as: end_time

Returns the value of attribute activityEndTime.



17
18
19
# File 'lib/actv/asset.rb', line 17

def activityEndTime
  @activityEndTime
end

#activityStartDateObject (readonly) Also known as: start_date

Returns the value of attribute activityStartDate.



17
18
19
# File 'lib/actv/asset.rb', line 17

def activityStartDate
  @activityStartDate
end

#activityStartTimeObject (readonly) Also known as: start_time

Returns the value of attribute activityStartTime.



17
18
19
# File 'lib/actv/asset.rb', line 17

def activityStartTime
  @activityStartTime
end

#assetDscObject (readonly)

Returns the value of attribute assetDsc.



17
18
19
# File 'lib/actv/asset.rb', line 17

def assetDsc
  @assetDsc
end

#assetGuidObject (readonly) Also known as: id

Returns the value of attribute assetGuid.



17
18
19
# File 'lib/actv/asset.rb', line 17

def assetGuid
  @assetGuid
end

#assetNameObject (readonly) Also known as: title

Returns the value of attribute assetName.



17
18
19
# File 'lib/actv/asset.rb', line 17

def assetName
  @assetName
end

#authorNameObject (readonly) Also known as: author_name

Returns the value of attribute authorName.



17
18
19
# File 'lib/actv/asset.rb', line 17

def authorName
  @authorName
end

#contactEmailAdrObject (readonly) Also known as: contact_email

Returns the value of attribute contactEmailAdr.



17
18
19
# File 'lib/actv/asset.rb', line 17

def contactEmailAdr
  @contactEmailAdr
end

#contactNameObject (readonly) Also known as: contact_name

Returns the value of attribute contactName.



17
18
19
# File 'lib/actv/asset.rb', line 17

def contactName
  @contactName
end

#contactPhoneObject (readonly) Also known as: contact_phone

Returns the value of attribute contactPhone.



17
18
19
# File 'lib/actv/asset.rb', line 17

def contactPhone
  @contactPhone
end

#createdDateObject (readonly) Also known as: created_at

Returns the value of attribute createdDate.



17
18
19
# File 'lib/actv/asset.rb', line 17

def createdDate
  @createdDate
end

#homePageUrlAdrObject (readonly) Also known as: home_page_url

Returns the value of attribute homePageUrlAdr.



17
18
19
# File 'lib/actv/asset.rb', line 17

def homePageUrlAdr
  @homePageUrlAdr
end

#is_articleObject (readonly)

Returns the value of attribute is_article.



17
18
19
# File 'lib/actv/asset.rb', line 17

def is_article
  @is_article
end

#is_eventObject (readonly)

Returns the value of attribute is_event.



17
18
19
# File 'lib/actv/asset.rb', line 17

def is_event
  @is_event
end

#isRecurringObject (readonly) Also known as: is_recurring?

Returns the value of attribute isRecurring.



17
18
19
# File 'lib/actv/asset.rb', line 17

def isRecurring
  @isRecurring
end

#modifiedDateObject (readonly) Also known as: updated_at

Returns the value of attribute modifiedDate.



17
18
19
# File 'lib/actv/asset.rb', line 17

def modifiedDate
  @modifiedDate
end

#publishDateObject (readonly) Also known as: published_at

Returns the value of attribute publishDate.



17
18
19
# File 'lib/actv/asset.rb', line 17

def publishDate
  @publishDate
end

#showContactObject (readonly) Also known as: show_contact?

Returns the value of attribute showContact.



17
18
19
# File 'lib/actv/asset.rb', line 17

def showContact
  @showContact
end

Instance Method Details

#channelsObject Also known as: asset_channels, assetChannels



66
67
68
69
70
# File 'lib/actv/asset.rb', line 66

def channels
  @asset_channels ||= Array(@attrs[:assetChannels]).map do |channel|
    ACTV::AssetChannel.new(channel)
  end
end

#componentsObject Also known as: asset_components, assetComponents



90
91
92
93
94
# File 'lib/actv/asset.rb', line 90

def components
  @asset_components ||= Array(@attrs[:assetComponents]).map do |component|
    ACTV::AssetComponent.new(component)
  end
end

#descriptionObject



126
127
128
# File 'lib/actv/asset.rb', line 126

def description
  @description ||= description_by_type 'Standard'
end

#description_by_type(type) ⇒ Object



135
136
137
138
# File 'lib/actv/asset.rb', line 135

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

#descriptionsObject Also known as: asset_descriptions, assetDescriptions



46
47
48
49
50
# File 'lib/actv/asset.rb', line 46

def descriptions
  @descriptions ||= Array(@attrs[:assetDescriptions]).map do |description|
    ACTV::AssetDescription.new(description)
  end
end

#evergreen?Boolean

Returns:

  • (Boolean)


177
178
179
# File 'lib/actv/asset.rb', line 177

def evergreen?
  self.evergreenAssetFlag.downcase == 'true' rescue false
end

#image_by_name(name) ⇒ Object



140
141
142
# File 'lib/actv/asset.rb', line 140

def image_by_name(name)
  self.images.find { |img| img.name.downcase == name.downcase }
end

#imagesObject Also known as: asset_images, assetImages



74
75
76
77
78
# File 'lib/actv/asset.rb', line 74

def images
  @images ||= Array(@attrs[:assetImages]).map do |img|
    ACTV::AssetImage.new(img)
  end
end

#is_article?Boolean

Returns:

  • (Boolean)


158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/actv/asset.rb', line 158

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
    # no categories so check the sourceSystem
    # this guid is equal to the Active.com Articles
    if self.sourceSystem.fetch(:legacyGuid, "").upcase == "CA4EA0B1-7377-470D-B20D-BF6BEA23F040"
      is_article = true
    end
  end

  is_article
end

#is_event?Boolean

Returns:

  • (Boolean)


149
150
151
152
153
154
155
156
# File 'lib/actv/asset.rb', line 149

def is_event?
  self.assetCategories.each do |category|
    if category[:category][:categoryTaxonomy].downcase.start_with?('event')
      return true
    end
  end
  false
end

#legacy_dataObject Also known as: asset_legacy_data, assetLegacyData



60
61
62
# File 'lib/actv/asset.rb', line 60

def legacy_data
  @legacy_data ||= ACTV::AssetLegacyData.new(@attrs[:assetLegacyData]) unless @attrs[:assetLegacyData].nil?
end

#placeObject



38
39
40
# File 'lib/actv/asset.rb', line 38

def place
  @place ||= ACTV::Place.new(@attrs[:place]) unless @attrs[:place].nil?
end

#place_timezoneObject



42
43
44
# File 'lib/actv/asset.rb', line 42

def place_timezone
  @timezone ||= place[:timezone] unless place[:timezone].nil?
end

#pricesObject Also known as: asset_prices, assetPrices



98
99
100
101
102
# File 'lib/actv/asset.rb', line 98

def prices
  @asset_prices ||= Array(@attrs[:assetPrices]).map do |price|
    ACTV::AssetPrice.new(price)
  end
end

#registration_statusObject Also known as: reg_status



181
182
183
# File 'lib/actv/asset.rb', line 181

def registration_status
  @registration_status ||= nil
end

#seo_url(systemName = 'as3') ⇒ Object



130
131
132
133
# File 'lib/actv/asset.rb', line 130

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_urlsObject Also known as: asset_seo_urls, assetSeoUrls



114
115
116
117
118
# File 'lib/actv/asset.rb', line 114

def seo_urls
  @seo_urls ||= Array(@attrs[:assetSeoUrls]).map do |seo_url|
    ACTV::AssetSeoUrl.new(seo_url)
  end
end

#statusObject Also known as: asset_status, assetStatus



54
55
56
# File 'lib/actv/asset.rb', line 54

def status
  @status ||= ACTV::AssetStatus.new(@attrs[:assetStatus]) unless @attrs[:assetStatus].nil?
end

#summaryObject



122
123
124
# File 'lib/actv/asset.rb', line 122

def summary
  @summary ||= description_by_type 'summary'
end

#tag_by_description(description) ⇒ Object



144
145
146
147
# File 'lib/actv/asset.rb', line 144

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

#tagsObject Also known as: asset_tags, assetTags



82
83
84
85
86
# File 'lib/actv/asset.rb', line 82

def tags
  @asset_tags ||= Array(@attrs[:assetTags]).map do |tag|
    ACTV::AssetTag.new(tag)
  end
end

#topicsObject Also known as: asset_topics, assetTopics



106
107
108
109
110
# File 'lib/actv/asset.rb', line 106

def topics
  @asset_topics ||= Array(@attrs[:assetTopics]).map do |topic|
    ACTV::AssetTopic.new(topic)
  end
end