Class: BrowserOfBabel::Page
- Defined in:
- lib/browser_of_babel/page.rb
Overview
Bottom-level holotheca in the library. Identifier is between 1 and 410. Contains 3200 characters:
- lowercase latin letters,
- digits,
- spaces,
- commas and periods.
Constant Summary
Constants inherited from Holotheca
Holotheca::DEFAULT_URL_FORMATTER
Instance Attribute Summary
Attributes included from Holotheca::Holarchy::ClassMethods
Attributes included from Holotheca::Holarchy
Instance Method Summary collapse
-
#[](start_or_range, length = nil) ⇒ Object
Get text from the page.
-
#text ⇒ String
Get the page’s contents as a blob of text.
-
#title ⇒ String
Get the page’s title (volume’s title + page number).
-
#volume_title ⇒ String
Get the volume’s title.
Methods inherited from Holotheca
holotheca_name, identifier_class, identifier_format, #initialize, #to_s, #to_s_part, #to_url, #to_url_part, url_format
Methods included from Holotheca::Holarchy::ClassMethods
Methods included from Holotheca::Holarchy
#depth, #dig, #down, #initialize, #path, #path_identifiers, #root, #up
Constructor Details
This class inherits a constructor from BrowserOfBabel::Holotheca
Instance Method Details
#page ⇒ Object #page ⇒ Object #page ⇒ Object
This performs a network request to fetch the page’s content.
Get text from the page. Character indices are 1-based.
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/browser_of_babel/page.rb', line 51 def [](start_or_range, length = nil) range = if start_or_range.is_a?(Range) (start_or_range.begin - 1)..(start_or_range.end - 1) elsif length (start_or_range - 1)..(start_or_range + length - 1) else (start_or_range - 1)..(start_or_range - 1) end text.[](range) end |
#text ⇒ String
This performs a network request to fetch the page’s content.
Get the page’s contents as a blob of text.
36 37 38 |
# File 'lib/browser_of_babel/page.rb', line 36 def text content.text end |
#title ⇒ String
This performs a network request to fetch the page’s content.
Get the page’s title (volume’s title + page number).
29 30 31 |
# File 'lib/browser_of_babel/page.rb', line 29 def title content.title end |
#volume_title ⇒ String
This performs a network request to fetch the page’s content.
Get the volume’s title.
21 22 23 24 |
# File 'lib/browser_of_babel/page.rb', line 21 def volume_title # @type var _ : String _ = title[/.+(?= \d+\z)/] end |