Class: MirrorDb::Model::Page

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/webget/mirror/database/models.rb

Instance Method Summary collapse

Instance Method Details

use incoming_pages or backlink_pages?



26
27
# File 'lib/webget/mirror/database/models.rb', line 26

has_many  :backlink_pages, :through => :incoming_links,
:source  => :from_page

#cachedObject

find a better name for not cached (was missing)? why? why not? cached a.k.a. downloaded to local cache



36
# File 'lib/webget/mirror/database/models.rb', line 36

scope  :cached,     -> { where( cached: true ) }

#htmlObject

for extname (file extensions) note - .html auto incl .htm !!



47
# File 'lib/webget/mirror/database/models.rb', line 47

scope  :html,  -> { where( extname: ['.html', '.htm']) }

#html?Boolean

Returns:

  • (Boolean)


50
# File 'lib/webget/mirror/database/models.rb', line 50

def html?()      extname == '.html' || extname == '.htm';  end

backlink (incoming)



21
22
23
# File 'lib/webget/mirror/database/models.rb', line 21

has_many  :incoming_links, class_name: 'Link',
                              foreign_key: 'to_page_id',
:dependent  => :delete_all

#incoming_pathsObject



31
# File 'lib/webget/mirror/database/models.rb', line 31

def incoming_paths() backlink_pages.pluck(:path); end

#linked_pagesObject

use outgoing_pages or linked_pages?



17
18
# File 'lib/webget/mirror/database/models.rb', line 17

has_many  :linked_pages,  :through => :outgoing_links,
:source  => :to_page

#not_cached?Boolean

Returns:

  • (Boolean)


56
# File 'lib/webget/mirror/database/models.rb', line 56

def not_cached?()  !cached?(); end

#not_foundObject

404 not_found



40
# File 'lib/webget/mirror/database/models.rb', line 40

scope  :not_found,  -> { where( http_status: 404 ) }

#not_found?Boolean

Returns:

  • (Boolean)


55
# File 'lib/webget/mirror/database/models.rb', line 55

def not_found?()  http_status == 404; end

#not_html?Boolean

Returns:

  • (Boolean)


51
# File 'lib/webget/mirror/database/models.rb', line 51

def not_html?()  !html?();  end

#outgoing_pathsObject



30
# File 'lib/webget/mirror/database/models.rb', line 30

def outgoing_paths() linked_pages.pluck(:path); end

#pdf?Boolean

Returns:

  • (Boolean)


52
# File 'lib/webget/mirror/database/models.rb', line 52

def pdf?()       extname == '.pdf'; end