Sha256: a6f2d1f6b66ea366dd8a3ec96f54ca6dcd78287ae9edbde576baf367481a3bb0

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

class UnorderedList < List
  include Widget

  public

  def initialize(app, list_opts={})
    self.app = app
    @list_opts = list_opts
    @list_opts ||= {}
    @list_items = []
  end

  def add(list_item)
    @list_items << list_item
  end

  # list_opts => {
  #   :bullet => one_of(BULLETS.keys),
  #   :background => app.background argument
  # }
  def show(opts={})
    show_options = {:margin_bottom => 10}.merge(@list_opts.merge(opts)) unless opts.nil?

    orientation = show_options[:orientation]
    orientation = :vertical if orientation.nil?
    case orientation.to_sym
    when :vertical
      app.stack(show_options) do
        @list_items.each do |item|
          item.app = app
          app.flow do
            item.show @list_opts
          end
        end
      end
    when :horizontal
      app.flow(show_options) do
        @list_items.each do |item|
          item.app = app
          app.stack(:width => 80) do
            item.show @list_opts
          end
        end
      end
    else
      app.error "Invalid orientation value: '#{orientation.to_s}'"
    end
  end

  def show_items
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
royw-shoeshine-0.0.2 lib/shoeshine/unordered_list.rb