Class: SafariBookmarksParser::BookmarkFolder
- Inherits:
-
Object
- Object
- SafariBookmarksParser::BookmarkFolder
- Defined in:
- lib/safari_bookmarks_parser/bookmark_folder.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#folder_names ⇒ Object
readonly
Returns the value of attribute folder_names.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(title:, folder_names:, children: []) ⇒ BookmarkFolder
constructor
A new instance of BookmarkFolder.
- #to_a ⇒ Object
- #to_h ⇒ Object
- #to_json(options) ⇒ Object
Constructor Details
#initialize(title:, folder_names:, children: []) ⇒ BookmarkFolder
Returns a new instance of BookmarkFolder.
7 8 9 10 11 |
# File 'lib/safari_bookmarks_parser/bookmark_folder.rb', line 7 def initialize(title:, folder_names:, children: []) @title = title @folder_names = folder_names @children = children end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
5 6 7 |
# File 'lib/safari_bookmarks_parser/bookmark_folder.rb', line 5 def children @children end |
#folder_names ⇒ Object (readonly)
Returns the value of attribute folder_names.
5 6 7 |
# File 'lib/safari_bookmarks_parser/bookmark_folder.rb', line 5 def folder_names @folder_names end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
5 6 7 |
# File 'lib/safari_bookmarks_parser/bookmark_folder.rb', line 5 def title @title end |
Instance Method Details
#empty? ⇒ Boolean
13 14 15 |
# File 'lib/safari_bookmarks_parser/bookmark_folder.rb', line 13 def empty? to_a.empty? end |
#to_a ⇒ Object
17 18 19 20 21 |
# File 'lib/safari_bookmarks_parser/bookmark_folder.rb', line 17 def to_a results = [] traverse(self, results) results end |
#to_h ⇒ Object
23 24 25 |
# File 'lib/safari_bookmarks_parser/bookmark_folder.rb', line 23 def to_h { 'title' => title, 'folder_names' => folder_names, 'children' => children.map(&:to_h) } end |
#to_json(options) ⇒ Object
27 28 29 |
# File 'lib/safari_bookmarks_parser/bookmark_folder.rb', line 27 def to_json() to_h.to_json() end |