Class: Vitreous::Share::Indexer
- Inherits:
-
Object
- Object
- Vitreous::Share::Indexer
- Defined in:
- lib/vitreous/share/indexer.rb
Instance Method Summary collapse
- #generate(structure = [@structure]) ⇒ Object
-
#initialize(structure) ⇒ Indexer
constructor
A new instance of Indexer.
- #json ⇒ Object
Constructor Details
#initialize(structure) ⇒ Indexer
Returns a new instance of Indexer.
4 5 6 |
# File 'lib/vitreous/share/indexer.rb', line 4 def initialize( structure ) @structure = structure end |
Instance Method Details
#generate(structure = [@structure]) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/vitreous/share/indexer.rb', line 8 def generate( structure = [@structure] ) Vitreous::Share::IndexerUtils.grouping( structure ).values.map do |e| { 'title' => Vitreous::Share::IndexerUtils.to_title( e[0]['name'] ), 'link' => Vitreous::Share::IndexerUtils.to_link( e[0]['path'] ), 'type' => e.any? { |e2| e2['type'] == 'directory' } ? 'collection' : 'item', 'elements' => generate( e[0]['elements'].sort { |x, y| x['name'] <=> y['name'] } ) }.merge( Vitreous::Share::IndexerUtils.( e ) ) end end |
#json ⇒ Object
19 20 21 |
# File 'lib/vitreous/share/indexer.rb', line 19 def json JSON.pretty_generate( generate[0] ) end |