Class: SlackTrello::TrelloHelpers::CreateCard

Inherits:
Object
  • Object
show all
Defined in:
lib/slack_trello/trello_helpers/create_card.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CreateCard

Returns a new instance of CreateCard.



5
6
7
8
9
# File 'lib/slack_trello/trello_helpers/create_card.rb', line 5

def initialize(args)
  @board_name = args.fetch(:board_name)
  @list_name = args.fetch(:list_name)
  @card_name = args.fetch(:card_name)
end

Instance Attribute Details

#board_nameObject (readonly)

Returns the value of attribute board_name.



3
4
5
# File 'lib/slack_trello/trello_helpers/create_card.rb', line 3

def board_name
  @board_name
end

#card_nameObject (readonly)

Returns the value of attribute card_name.



3
4
5
# File 'lib/slack_trello/trello_helpers/create_card.rb', line 3

def card_name
  @card_name
end

#list_nameObject (readonly)

Returns the value of attribute list_name.



3
4
5
# File 'lib/slack_trello/trello_helpers/create_card.rb', line 3

def list_name
  @list_name
end

Instance Method Details

#create_cardObject



17
18
19
20
21
22
# File 'lib/slack_trello/trello_helpers/create_card.rb', line 17

def create_card
  card = Trello::Card.new
  card.name = card_name
  card.list_id = trello_list.id
  card.save
end

#first_or_createObject



11
12
13
14
15
# File 'lib/slack_trello/trello_helpers/create_card.rb', line 11

def first_or_create
  card = Lookup.card(board_name, list_name, card_name)
  return card if card
  create_card
end

#trello_listObject



24
25
26
# File 'lib/slack_trello/trello_helpers/create_card.rb', line 24

def trello_list
  Lookup.list(board_name, list_name)
end