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.131 lib/markdown/ul.rb
tbpgr_utils-0.0.130 lib/markdown/ul.rb
tbpgr_utils-0.0.129 lib/markdown/ul.rb
tbpgr_utils-0.0.128 lib/markdown/ul.rb
tbpgr_utils-0.0.127 lib/markdown/ul.rb
tbpgr_utils-0.0.126 lib/markdown/ul.rb
tbpgr_utils-0.0.125 lib/markdown/ul.rb
tbpgr_utils-0.0.124 lib/markdown/ul.rb
tbpgr_utils-0.0.123 lib/markdown/ul.rb
tbpgr_utils-0.0.122 lib/markdown/ul.rb
tbpgr_utils-0.0.121 lib/markdown/ul.rb
tbpgr_utils-0.0.120 lib/markdown/ul.rb
tbpgr_utils-0.0.119 lib/markdown/ul.rb
tbpgr_utils-0.0.118 lib/markdown/ul.rb
tbpgr_utils-0.0.117 lib/markdown/ul.rb
tbpgr_utils-0.0.116 lib/markdown/ul.rb
tbpgr_utils-0.0.115 lib/markdown/ul.rb
tbpgr_utils-0.0.114 lib/markdown/ul.rb
tbpgr_utils-0.0.113 lib/markdown/ul.rb
tbpgr_utils-0.0.112 lib/markdown/ul.rb