Class: Client

Inherits:
Object
  • Object
show all
Defined in:
lib/trellist/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#boardObject

Returns the value of attribute board.



41
42
43
# File 'lib/trellist/client.rb', line 41

def board
  @board
end

#cardsObject

Returns the value of attribute cards.



41
42
43
# File 'lib/trellist/client.rb', line 41

def cards
  @cards
end

#labelsObject

Returns the value of attribute labels.



41
42
43
# File 'lib/trellist/client.rb', line 41

def labels
  @labels
end

#listsObject

Returns the value of attribute lists.



41
42
43
# File 'lib/trellist/client.rb', line 41

def lists
  @lists
end

Instance Method Details

#board_labelsObject



58
59
60
# File 'lib/trellist/client.rb', line 58

def board_labels
  @labels = Trello::Board.find(@board).labels
end


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_listsObject



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