class RubyCat::Catalog

Attributes

cards[R]

Public Class Methods

new() click to toggle source
# File lib/rubycat/catalog.rb, line 10
def initialize
  @cards = []
end

Public Instance Methods

add( cards ) click to toggle source
# File lib/rubycat/catalog.rb, line 14
def add( cards )
  @cards +=  cards.map { |card| Card.new(card) }   ## convert to RubyCat card
end
render() click to toggle source
# File lib/rubycat/catalog.rb, line 40
def render
  ## render to json
  puts "--snip--"

  ary = []

  @cards.each do |card|
    h = card.to_hash
    ## pp h
    ary << h
  end

  puts "--snip--"
  puts JSON.pretty_generate( ary )
end
sync( opts={} ) click to toggle source
# File lib/rubycat/catalog.rb, line 18
def sync( opts={} )   ## change name to populate/autofill, etc. ??
  ## get (extra) data from rubygems via api

  gems = RubyGemsService.new

  @cards.each_with_index do |card,i|

    if card.gem_url
      json = gems.info( card.name )
      pp json

      card.sync_gems_info( json )
    end

    pp card

    ### for debugging/testing; stop after processing x (e.g. 2) recs
    break    if opts[:limit] && i >= opts[:limit].to_i   ## e.g. i > 2 etc.
  end
end