Class: Epuber::NavFile
- Inherits:
-
Object
show all
- Defined in:
- lib/epuber/from_file/nav_file.rb
Defined Under Namespace
Classes: LandmarkItem, NavItem
Constant Summary
collapse
- LANDMARKS_MAP =
{
'cover' => :landmark_cover,
'bodymatter' => :landmark_start_page,
'copyright-page' => :landmark_copyright,
'toc' => :landmark_toc,
}.freeze
- MODE_NCX =
:ncx
- MODE_XHTML =
:xhtml
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(document, mode) ⇒ NavFile
Returns a new instance of NavFile.
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/epuber/from_file/nav_file.rb', line 95
def initialize(document, mode)
raise ArgumentError, 'mode must be :ncx or :xhtml' unless [MODE_NCX, MODE_XHTML].include?(mode)
@document = Nokogiri::XML(document)
@document.remove_namespaces!
@mode = mode
@items = _parse
@landmarks = _parse_landmarks
end
|
Instance Attribute Details
#document ⇒ Nokogiri::XML::Document
78
79
80
|
# File 'lib/epuber/from_file/nav_file.rb', line 78
def document
@document
end
|
#items ⇒ Array<NavItem>
86
87
88
|
# File 'lib/epuber/from_file/nav_file.rb', line 86
def items
@items
end
|
90
91
92
|
# File 'lib/epuber/from_file/nav_file.rb', line 90
def landmarks
@landmarks
end
|
#mode ⇒ :ncx, :xhtml
82
83
84
|
# File 'lib/epuber/from_file/nav_file.rb', line 82
def mode
@mode
end
|
Instance Method Details
#find_by_href(href, ignore_fragment: false) ⇒ NavItem?
112
113
114
|
# File 'lib/epuber/from_file/nav_file.rb', line 112
def find_by_href(href, ignore_fragment: false)
@items.find { |item| item.find_by_href(href, ignore_fragment: ignore_fragment) }
end
|