Class: Nucleo::Models::FeedTypes::Seo::Page::ImgAlt

Inherits:
Base
  • Object
show all
Defined in:
lib/nucleo/models/feed_types/seo/page/img_alt.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#check_count, #checks, #element, #element_content, #element_content?, #find_content, #points

Methods inherited from Base

#<=>, #analytics_category?, #category, #children, #children?, #context, #executed_at, #id, #initialize, #page, #page?, #page_context?, #page_recommendation_id, #record_id, #seo_category?, #site_analytic_id, #site_context?, #site_id, #status, #type

Constructor Details

This class inherits a constructor from Nucleo::Models::FeedTypes::Base

Class Method Details

.feed_summaryString

Returns the class level feed summary title

Returns:

  • (String)


53
54
55
# File 'lib/nucleo/models/feed_types/seo/page/img_alt.rb', line 53

def self.feed_summary
  "<strong>img alt</strong> feed summary"
end

Instance Method Details

#alt_contentObject



46
47
48
# File 'lib/nucleo/models/feed_types/seo/page/img_alt.rb', line 46

def alt_content
  self.element.alt
end

#feed_summaryString

Delegate to the class level feed summary

Returns:

  • (String)


60
61
62
# File 'lib/nucleo/models/feed_types/seo/page/img_alt.rb', line 60

def feed_summary
  self.class.feed_summary
end

#headlineString

Returns the headline based on the length of the content

Returns:

  • (String)


67
68
69
# File 'lib/nucleo/models/feed_types/seo/page/img_alt.rb', line 67

def headline
  "img alt headline"
end

#image_src(site_url = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/nucleo/models/feed_types/seo/page/img_alt.rb', line 11

def image_src(site_url = nil)
  url_template = '%{scheme}://%{host}/%{path}?%{query}#%{fragment}'

  if site_url.present?
    begin
      site_host = URI(site_url).host
    rescue
      Nucleo::Client.configuration.logger.fatal("Unable to parse site_url %s" % [site_url])
    end
  end

  img = self.element.src
  begin
    url = URI(img)

    # Check if url is a valid http/https url
    if url.kind_of?(URI::HTTP)
      return url.to_s
    end

    # Attempt to create new url from fragments
    new_url = URI(url_template % {
      scheme: (url.scheme or 'http'),
      host: (url.host or site_host),
      path: url.path,
      query: url.query,
      fragment: url.fragment
    })
    return new_url.to_s if new_url.kind_of?(URI::HTTP)

  rescue
    Nucleo::Client.configuration.logger.fatal("Could not validate image url %s" % [img])
  end
end

#long_summaryString

Returns the detailed summary

Returns:

  • (String)


74
75
76
# File 'lib/nucleo/models/feed_types/seo/page/img_alt.rb', line 74

def long_summary
  "img alts long summary"
end

#short_summaryString

Returns the short summary

Returns:

  • (String)


81
82
83
# File 'lib/nucleo/models/feed_types/seo/page/img_alt.rb', line 81

def short_summary
  "Images with <strong>Alt</strong> text are searchable with images search."
end