Sha256: 7134a14f1f60c7ae600bd8ea9c9efad9a9ce56512183accd5527a65ca621b7ee

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 KB

Contents

module Tr3llo
  module View
    module Card
      module List
        extend self

        def render(list, cards)
          <<~TEMPLATE.strip
          #{Utils.paint("##{list.name}", "purple")}
          #{"=" * (list.name.length + 1)}
          #{render_cards(cards)}
          TEMPLATE
        end

        private

        def render_cards(cards)
          if cards.any?
            cards
              .map do |card|
                key_tag = Utils.format_key_tag(card.id, card.shortcut)

                "#{key_tag} #{card.name}#{render_labels(card.labels)}#{render_members(card.members)}"
              end
              .join("\n")
          else
            "(No cards)"
          end
        end

        def render_labels(labels)
          if labels.any?
            " [" + labels.map { |label| format_label(label) }.join(", ") + "]"
          else
            ""
          end
        end

        def render_members(members)
          if members.any?
            " [" + members.map { |member| Utils.format_user(member) }.join(", ") + "]"
          else
            ""
          end
        end

        def format_label(label)
          if label.color
            Utils.paint("##{label.name}", label.color)
          else
            "##{label.name}"
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
3llo-1.3.1 lib/3llo/view/card/list.rb
3llo-1.3.1.pre.rc.0 lib/3llo/view/card/list.rb
3llo-1.2.0 lib/3llo/view/card/list.rb
3llo-1.1.0 lib/3llo/view/card/list.rb
3llo-1.0.0 lib/3llo/view/card/list.rb
3llo-1.0.0.pre.rc.0 lib/3llo/view/card/list.rb