module Tr3llo::Command::Card::Move

Public Instance Methods

execute(key, board_id) click to toggle source
# File lib/3llo/command/card/move.rb, line 7
def execute(key, board_id)
  card_id = Entities.parse_id(:card, key)
  assert_card_id!(card_id, key)

  interface = Application.fetch_interface!()

  interface.print_frame do
    selected_list_id = select_list(interface, board_id)

    API::Card.move_to_list(card_id, selected_list_id)
    interface.puts("Card has been moved.")
  end
end

Private Instance Methods

assert_card_id!(card_id, key) click to toggle source
# File lib/3llo/command/card/move.rb, line 36
def assert_card_id!(card_id, key)
  raise InvalidArgumentError.new("#{key.inspect} is not a valid card key") unless card_id
end
select_list(interface, board_id) click to toggle source
# File lib/3llo/command/card/move.rb, line 23
def select_list(interface, board_id)
  list_options =
    API::List
      .find_all_by_board(board_id)
      .map { |list| [list.name, list.id] }
      .to_h()

  interface.input.select(
    "Choose the list to be moved to",
    list_options
  )
end