Think about exercise 6
This commit is contained in:
parent
8a76966062
commit
2fb10a5042
|
@ -53,6 +53,7 @@ defmodule Issues.CLI do
|
|||
|> decode_response()
|
||||
|> sort_into_descending_order
|
||||
|> last(count)
|
||||
|> show_issues_as_table
|
||||
end
|
||||
|
||||
def decode_response({:ok, body}), do: body
|
||||
|
@ -71,4 +72,20 @@ defmodule Issues.CLI do
|
|||
|> Enum.take(count)
|
||||
|> Enum.reverse
|
||||
end
|
||||
|
||||
def show_issues_as_table(issues_list) do
|
||||
# get the width of id-column = length(max(all_ids)) + 2
|
||||
# do the same for created_at and title
|
||||
|
||||
IO.puts "#id | created_at | title"
|
||||
|
||||
issues_list
|
||||
|> Enum.each(fn issue -> IO.puts "#{Map.get(issue, "id")} | #{Map.get(issue, "created_at")} | #{Map.get(issue, "title")}" end)
|
||||
|
||||
# list is a list of maps
|
||||
# print #id | created_at | title
|
||||
# print ----+------------+------
|
||||
# print issue.id | issue.created_at | issue.title
|
||||
#
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue