Class: Client
- Inherits:
-
Object
- Object
- Client
- Defined in:
- lib/trellist/client.rb
Instance Attribute Summary collapse
-
#board ⇒ Object
Returns the value of attribute board.
-
#cards ⇒ Object
Returns the value of attribute cards.
-
#labels ⇒ Object
Returns the value of attribute labels.
-
#lists ⇒ Object
Returns the value of attribute lists.
Instance Method Summary collapse
- #board_labels ⇒ Object
- #generate_links(format: 'markdown', prefix: '', suffix: '') ⇒ Object
- #get_board_lists ⇒ Object
-
#initialize(board_id:, key:, token:) ⇒ Client
constructor
A new instance of Client.
- #list_cards(list_id, label: nil) ⇒ Object
Constructor Details
#initialize(board_id:, key:, token:) ⇒ Client
Returns a new instance of Client.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/trellist/client.rb', line 43 def initialize(board_id:, key:, token:) @board = board_id @key = key @token = token Trello.configure do |config| config.developer_public_key = key config.member_token = token end end |
Instance Attribute Details
#board ⇒ Object
Returns the value of attribute board.
41 42 43 |
# File 'lib/trellist/client.rb', line 41 def board @board end |
#cards ⇒ Object
Returns the value of attribute cards.
41 42 43 |
# File 'lib/trellist/client.rb', line 41 def cards @cards end |
#labels ⇒ Object
Returns the value of attribute labels.
41 42 43 |
# File 'lib/trellist/client.rb', line 41 def labels @labels end |
#lists ⇒ Object
Returns the value of attribute lists.
41 42 43 |
# File 'lib/trellist/client.rb', line 41 def lists @lists end |
Instance Method Details
#board_labels ⇒ Object
58 59 60 |
# File 'lib/trellist/client.rb', line 58 def board_labels @labels = Trello::Board.find(@board).labels end |
#generate_links(format: 'markdown', prefix: '', suffix: '') ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/trellist/client.rb', line 67 def generate_links(format: 'markdown', prefix: '', suffix: '') case format when 'markdown' @cards.map { |card| card.as_markdown(prefix: prefix, suffix: suffix) } when 'plain' @cards.map(&:short_url) when 'html' @cards.map { |card| card.as_html(prefix: prefix, suffix: suffix) } when 'titles-only' @cards.map { |card| card.as_plain_title(prefix: prefix, suffix: suffix) } when 'slides' @cards.map { |card| card.as_deckset_markdown } else @cards.map(&:inspect) end end |
#get_board_lists ⇒ Object
54 55 56 |
# File 'lib/trellist/client.rb', line 54 def get_board_lists @lists = Trello::Board.find(@board).lists end |
#list_cards(list_id, label: nil) ⇒ Object
62 63 64 65 |
# File 'lib/trellist/client.rb', line 62 def list_cards(list_id, label: nil) @cards = Trello::List.find(list_id).cards @cards.select! { |card| card.labels.map(&:name).include?(label) } if label end |