Sha256: e5697a4943891a90e34a4330e72f5c92de1f7520e004e6db4184e9a776deccfa

Contents?: true

Size: 699 Bytes

Versions: 43

Compression:

Stored size: 699 Bytes

Contents

# encoding: utf-8

class MarkdownString
  # Return markdown ul from text
  #
  # === Example
  #
  # case list
  #
  #   MarkdownString.ul(%w{a b c})
  #
  # result
  #
  #   * a
  #   * b
  #   * c
  #
  # case not list
  #
  #   MarkdownString.ul("test") # => "test"
  #
  # case nil list
  #
  #   MarkdownString.ul([nil, nil])
  #
  # result
  #
  #   *
  #   *
  #
  # case empty list
  #
  #   MarkdownString.ul([]) # => ""
  #
  def self.ul(list)
    return list unless list.is_a?(Array)
    return '' if list.empty?
    list.reduce([]) do |ret, elm|
      elm = '' if elm.nil?
      ret << "* #{elm}"
      ret
    end.join("\n") + "\n"
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.111 lib/markdown/ul.rb
tbpgr_utils-0.0.110 lib/markdown/ul.rb
tbpgr_utils-0.0.109 lib/markdown/ul.rb