class Troo::Presenters::List

Attributes

list[R]

Public Class Methods

new(list, options = {}) click to toggle source

@param [Troo::List] @return [Troo::Presenters::List]

# File lib/troo/presenters/list.rb, line 8
def initialize(list, options = {})
  @list, @options = list, options
end

Public Instance Methods

render_cards() click to toggle source

@return [String]

# File lib/troo/presenters/list.rb, line 39
def render_cards
  output.spacer do
    list.cards.map do |card|
      output.render Presenters::Resource.list_view(card)
    end
  end
end
render_list() click to toggle source

@return [String]

# File lib/troo/presenters/list.rb, line 24
def render_list
  output.render Presenters::Resource.list_view(list)

  output.indent do
    if list.cards.empty?
      output.spacer do
        output.render error('No cards were found.')
      end
    else
      render_cards
    end
  end
end
show() click to toggle source

@return [String]

# File lib/troo/presenters/list.rb, line 13
def show
  output.render Presenters::Resource.list_view(list.board)

  output.spacer

  output.indent do
    render_list
  end
end

Private Instance Methods

defaults() click to toggle source
# File lib/troo/presenters/list.rb, line 59
def defaults
  {
    output: Troo::Output.new
  }
end
options() click to toggle source
# File lib/troo/presenters/list.rb, line 55
def options
  defaults.merge!(@options)
end
output() click to toggle source
# File lib/troo/presenters/list.rb, line 51
def output
  @output ||= options.fetch(:output)
end