Class: WebAuthor::Page

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/web_author/page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:) ⇒ Page

Returns a new instance of Page.



15
16
17
18
# File 'lib/web_author/page.rb', line 15

def initialize(url:)
  @url = T.let(url, String)
  @page_content = T.let(nil, T.nilable(Nokogiri::XML::Document))
end

Instance Attribute Details

#page_contentObject (readonly)

Returns the value of attribute page_content.



12
13
14
# File 'lib/web_author/page.rb', line 12

def page_content
  @page_content
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'lib/web_author/page.rb', line 9

def url
  @url
end

Instance Method Details

#authorObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/web_author/page.rb', line 21

def author
  fetch_page_content unless page_content

  STRATEGIES.each do |strategy_class|
    author = strategy_class.new(T.must(page_content)).author
    return author if author
  end

  nil
end