Class: Seo::ArticleLinkAuditor::AuditResult

Inherits:
Data
  • Object
show all
Defined in:
app/services/seo/article_link_auditor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(internal_checked: 0, internal_broken: [], external_checked: 0, external_broken: [], audited_at: Time.current) ⇒ AuditResult

Returns a new instance of AuditResult.



25
26
27
28
29
# File 'app/services/seo/article_link_auditor.rb', line 25

def initialize(
  internal_checked: 0, internal_broken: [],
  external_checked: 0, external_broken: [],
  audited_at: Time.current
) = super

Instance Attribute Details

#audited_atObject (readonly)

Returns the value of attribute audited_at

Returns:

  • (Object)

    the current value of audited_at



20
21
22
# File 'app/services/seo/article_link_auditor.rb', line 20

def audited_at
  @audited_at
end

#external_brokenObject (readonly)

Returns the value of attribute external_broken

Returns:

  • (Object)

    the current value of external_broken



20
21
22
# File 'app/services/seo/article_link_auditor.rb', line 20

def external_broken
  @external_broken
end

#external_checkedObject (readonly)

Returns the value of attribute external_checked

Returns:

  • (Object)

    the current value of external_checked



20
21
22
# File 'app/services/seo/article_link_auditor.rb', line 20

def external_checked
  @external_checked
end

#internal_brokenObject (readonly)

Returns the value of attribute internal_broken

Returns:

  • (Object)

    the current value of internal_broken



20
21
22
# File 'app/services/seo/article_link_auditor.rb', line 20

def internal_broken
  @internal_broken
end

#internal_checkedObject (readonly)

Returns the value of attribute internal_checked

Returns:

  • (Object)

    the current value of internal_checked



20
21
22
# File 'app/services/seo/article_link_auditor.rb', line 20

def internal_checked
  @internal_checked
end

Instance Method Details

#all_valid?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/services/seo/article_link_auditor.rb', line 31

def all_valid?
  internal_broken.empty? && external_broken.empty?
end

#to_hObject



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/services/seo/article_link_auditor.rb', line 39

def to_h
  {
    audited_at: audited_at.iso8601,
    internal: {
      checked: internal_checked,
      broken: internal_broken.map { |b| b.respond_to?(:to_h) ? b.to_h : b }
    },
    external: {
      checked: external_checked,
      broken: external_broken.map { |b| b.respond_to?(:to_h) ? b.to_h : b }
    }
  }
end

#total_brokenObject



35
36
37
# File 'app/services/seo/article_link_auditor.rb', line 35

def total_broken
  internal_broken.size + external_broken.size
end