Class: HbExporter::User

Inherits:
Object
  • Object
show all
Includes:
Helper::RecursivelyFetch
Defined in:
lib/hb_exporter/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper::RecursivelyFetch

#recursively_fetch

Constructor Details

#initialize(name) ⇒ User

Returns a new instance of User.



11
12
13
# File 'lib/hb_exporter/user.rb', line 11

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/hb_exporter/user.rb', line 9

def name
  @name
end

Instance Method Details

#boardsObject



39
40
41
42
43
# File 'lib/hb_exporter/user.rb', line 39

def boards
  @boards ||= fetch_boards.map do |data|
    Board.new(data['board_id'], title: data['title'], desc: data['description'], pins_count: data['pin_count'])
  end
end

#export_all_boardsObject



34
35
36
# File 'lib/hb_exporter/user.rb', line 34

def export_all_boards
  bards
end

#list_boardsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/hb_exporter/user.rb', line 16

def list_boards
  return if boards.empty?

  id_max_len    = [2, boards.map(&:id).max.to_s.size].max
  count_max_len = [5, boards.map(&:pins_count).max.to_s.size].max

  puts [
    "id".rjust(id_max_len),
    "count".ljust(count_max_len),
    "title"
  ].join(" ")

  boards.each do |b|
    puts "#{b.id.to_s.rjust(id_max_len).cyan} #{b.pins_count.to_s.ljust(count_max_len).cyan} #{b.title.to_s.bold} - #{b.desc}"
  end
end