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.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/trellist/client.rb', line 30 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.
28 29 30 |
# File 'lib/trellist/client.rb', line 28 def board @board end |
#cards ⇒ Object
Returns the value of attribute cards.
28 29 30 |
# File 'lib/trellist/client.rb', line 28 def cards @cards end |
#labels ⇒ Object
Returns the value of attribute labels.
28 29 30 |
# File 'lib/trellist/client.rb', line 28 def labels @labels end |
#lists ⇒ Object
Returns the value of attribute lists.
28 29 30 |
# File 'lib/trellist/client.rb', line 28 def lists @lists end |
Instance Method Details
#board_labels ⇒ Object
45 46 47 |
# File 'lib/trellist/client.rb', line 45 def board_labels @labels = Trello::Board.find(@board).labels end |
#generate_links(format: 'markdown', prefix: '', suffix: '') ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/trellist/client.rb', line 54 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) } else @cards.map(&:inspect) end end |
#get_board_lists ⇒ Object
41 42 43 |
# File 'lib/trellist/client.rb', line 41 def get_board_lists @lists = Trello::Board.find(@board).lists end |
#list_cards(list_id, label: nil) ⇒ Object
49 50 51 52 |
# File 'lib/trellist/client.rb', line 49 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 |