Module: Hackpad::Cli::Padlist

Defined in:
lib/hackpad/cli/padlist.rb

Class Method Summary collapse

Class Method Details

.get_list(refresh = false, output = STDOUT) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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_newObject



34
35
36
37
38
39
40
41
42
43
44
45
# 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) ⇒ Object



28
29
30
31
32
# 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