Class: RubyCat::Catalog

Inherits:
Object
  • Object
show all
Defined in:
lib/rubycat/catalog.rb

Instance Method Summary collapse

Constructor Details

#initializeCatalog

Returns a new instance of Catalog.



8
9
10
# File 'lib/rubycat/catalog.rb', line 8

def initialize
  @cards = []
end

Instance Method Details

#add(cards) ⇒ Object



12
13
14
# File 'lib/rubycat/catalog.rb', line 12

def add( cards )
  @cards +=  cards.map { |card| Card.new(card) }   ## convert to RubyCat card
end

#renderObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rubycat/catalog.rb', line 16

def render
  ## render to json
  puts "--snip--"

  ary = []

  @cards.each do |card|
    h = {
      name:       card.name,
      gem_url:    card.gem_url,
      github_url: card.github_url,
      categories: card.categories
    }
    pp h
    ary << h
  end

  puts "--snip--"
  puts JSON.pretty_generate( ary )
end