class Troo::Commands::Move::Card
Attributes
board_id[R]
card_id[R]
list_id[R]
Public Class Methods
dispatch(card_id, list_id, board_id = nil)
click to toggle source
@param [String] @param [String] @param [String] @return [String]
# File lib/troo/cli/commands/move/card.rb, line 10 def dispatch(card_id, list_id, board_id = nil) new(card_id, list_id, board_id).move end
new(card_id, list_id, board_id = nil)
click to toggle source
@param [String] @param [String] @param [String] @return [Troo::Commands::Move::Card]
# File lib/troo/cli/commands/move/card.rb, line 19 def initialize(card_id, list_id, board_id = nil) @card_id, @list_id, @board_id = card_id, list_id, board_id end
Public Instance Methods
move()
click to toggle source
@return [String]
# File lib/troo/cli/commands/move/card.rb, line 24 def move return 'Card cannot be found.' if card_not_found? return 'List cannot be found.' if list_not_found? return 'Board cannot be found.' if board_not_found? return success if moved error end
Private Instance Methods
board()
click to toggle source
# File lib/troo/cli/commands/move/card.rb, line 90 def board @board ||= Troo::Board.retrieve(board_id) end
board_name()
click to toggle source
# File lib/troo/cli/commands/move/card.rb, line 86 def board_name board.decorator.name end
board_not_found?()
click to toggle source
# File lib/troo/cli/commands/move/card.rb, line 94 def board_not_found? board_specified? && board.nil? end
board_specified?()
click to toggle source
# File lib/troo/cli/commands/move/card.rb, line 98 def board_specified? !board_id.nil? end
card()
click to toggle source
# File lib/troo/cli/commands/move/card.rb, line 66 def card @card ||= Troo::Card.retrieve(card_id) end
card_name()
click to toggle source
# File lib/troo/cli/commands/move/card.rb, line 62 def card_name card.decorator.name end
card_not_found?()
click to toggle source
# File lib/troo/cli/commands/move/card.rb, line 70 def card_not_found? card.nil? end
error()
click to toggle source
# File lib/troo/cli/commands/move/card.rb, line 58 def error 'Card could not be moved.' end
list()
click to toggle source
# File lib/troo/cli/commands/move/card.rb, line 78 def list @list ||= Troo::List.retrieve(list_id) end
list_name()
click to toggle source
# File lib/troo/cli/commands/move/card.rb, line 74 def list_name list.decorator.name end
list_not_found?()
click to toggle source
# File lib/troo/cli/commands/move/card.rb, line 82 def list_not_found? list.nil? end
moved()
click to toggle source
# File lib/troo/cli/commands/move/card.rb, line 36 def moved if board_specified? @moved ||= Remote::Persistence::MoveCard .with(card.external_id, list.external_id, board.external_id) else @moved ||= Remote::Persistence::MoveCard .with(card.external_id, list.external_id) end end
success()
click to toggle source
# File lib/troo/cli/commands/move/card.rb, line 49 def success if board_specified? "Card '#{card_name}' moved to '#{list_name}' " \ "on '#{board_name}'." else "Card '#{card_name}' moved to '#{list_name}'." end end