class Epuber::NavFile::NavItem
Attributes
children[RW]
@return [Array<NavItem>]
href[RW]
@return [String]
title[RW]
@return [String]
Public Class Methods
new(href, title)
click to toggle source
@param [String] href @param [String] title
# File lib/epuber/from_file/nav_file.rb, line 16 def initialize(href, title) @href = href @title = title @children = [] end
Public Instance Methods
find_by_href(other_href, ignore_fragment: false)
click to toggle source
@param [String] other_href @param [Boolean] ignore_fragment
@return [NavItem, nil]
# File lib/epuber/from_file/nav_file.rb, line 27 def find_by_href(other_href, ignore_fragment: false) if ignore_fragment other_href = other_href.split('#').first self_href = @href.split('#').first return self if self_href == other_href elsif @href == other_href return self end @children.find { |item| item.find_by_href(other_href) } end