module Hackpad::Cli::Padlist

Public Instance Methods

get_list(refresh = false, output = STDOUT) click to toggle source
# File lib/hackpad/cli/padlist.rb, line 11
def get_list(refresh = false, output = STDOUT)
  all = []
  if refresh || !Store.exist?('padlist')
    output.print 'Refreshing '
    list = Api.list
    list.each do |a|
      output.print '.'
      all << get_pad(a, refresh)
    end
    output.puts ' all done.'
    Store.save_list all
  else
    all = Store.read_list
  end
  all
end
get_new() click to toggle source
# File lib/hackpad/cli/padlist.rb, line 34
def get_new
  all = []
  list = Api.list
  list.each do |a|
    pad = Pad.new a
    unless pad.cached?
      pad.load 'txt'
      all << OpenStruct.new(id: a, title: pad.title)
    end
  end
  all
end
get_pad(id, refresh = false) click to toggle source
# File lib/hackpad/cli/padlist.rb, line 28
def get_pad(id, refresh = false)
  pad = Pad.new id
  pad.load 'txt', refresh
  OpenStruct.new(id: id, title: pad.title)
end