Class: ACTV::Author

Inherits:
Asset show all
Defined in:
lib/actv/author.rb

Constant Summary

Constants included from AssetSourceSystem

ACTV::AssetSourceSystem::SOURCE_SYSTEM_HASH

Instance Attribute Summary

Attributes inherited from Asset

#activityEndDate, #activityEndTime, #activityStartDate, #activityStartTime, #assetDsc, #assetGuid, #assetName, #authorName, #contactEmailAdr, #contactName, #contactPhone, #contactTxt, #createdDate, #currencyCd, #homePageUrlAdr, #isRecurring, #is_article, #is_event, #modifiedDate, #publishDate, #regReqGenderCd, #regReqMaxAge, #regReqMinAge, #showContact

Attributes inherited from Base

#attrs

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Asset

#attribute_paths, #attributes, #category_is?, #channels, #components, #description, #description_by_type, #descriptions, #endurance_id, #evergreen?, #first_topic, #first_topic_name, #first_topic_path, from_response, #has_location?, #has_volume_based_price?, #image, #image_by_name, #image_path, #image_with_placeholder, #images, inherited, #initialize, #is_article?, #is_event?, #is_video?, #kids?, #legacy_data, #location_path, #media_url, #meta_interest_paths, #meta_interests, #org_timezone, #organization, #place, #place_timezone, #prices, #recurrences, #references, #registration_status, #seo_url, #seo_urls, #sponsored?, #status, #sub_2_topic, #sub_2_topic_path, #sub_3_topic, #sub_3_topic_path, #sub_4_topic, #sub_4_topic_path, #sub_topic, #sub_topic_path, #summary, #tag_by_description, #tags, #topics, types, #version, #visible?

Methods included from AssetSourceSystem

#kids_friendly_source_system?

Methods inherited from Identity

#==, #id, #initialize

Methods inherited from Base

#[], attr_reader, define_attribute_method, define_predicate_method, define_uri_method, #delete, from_response, #initialize, #memoize, #method_missing, object_attr_reader, #respond_to?, #to_hash, #update, uri_attr_reader

Constructor Details

This class inherits a constructor from ACTV::Asset

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ACTV::Base

Class Method Details

.build_from_article(article_hash) ⇒ Object



6
7
8
# File 'lib/actv/author.rb', line 6

def self.build_from_article article_hash
  new article_hash
end

.valid?(response) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/actv/author.rb', line 10

def self.valid? response
  ACTV::AuthorValidator.new(response).valid?
end

Instance Method Details

#bioObject



22
23
24
25
26
27
# File 'lib/actv/author.rb', line 22

def bio
  @bio ||= begin
    bio_node = from_footer 'div.author-text'
    bio_node.inner_html unless bio_node.nil?
  end
end


18
19
20
# File 'lib/actv/author.rb', line 18

def footer
  @footer ||= description_by_type 'authorFooter'
end

#image_urlObject



39
40
41
42
43
44
45
# File 'lib/actv/author.rb', line 39

def image_url
  if photo.url && photo.url.start_with?("/")
    "https://www.active.com#{photo.url}"
  else
    photo.url
  end
end

#nameObject



14
15
16
# File 'lib/actv/author.rb', line 14

def name
  name_from_footer.presence || self.author_name.presence
end


47
48
49
50
51
52
# File 'lib/actv/author.rb', line 47

def name_from_footer
  @name_from_footer ||= begin
    name_node = from_footer 'span.author-name'
    name_node.text unless name_node.nil?
  end
end

#photoObject



29
30
31
32
33
34
35
36
37
# File 'lib/actv/author.rb', line 29

def photo
  @photo ||= begin
    image_node = from_footer 'div.signature-block-photo img'
    if image_node
      url = image_node.attribute('src').to_s
      ACTV::AssetImage.new imageUrlAdr: url
    end
  end
end