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.151 lib/markdown/ul.rb
tbpgr_utils-0.0.150 lib/markdown/ul.rb
tbpgr_utils-0.0.149 lib/markdown/ul.rb
tbpgr_utils-0.0.148 lib/markdown/ul.rb
tbpgr_utils-0.0.147 lib/markdown/ul.rb
tbpgr_utils-0.0.146 lib/markdown/ul.rb
tbpgr_utils-0.0.145 lib/markdown/ul.rb
tbpgr_utils-0.0.144 lib/markdown/ul.rb
tbpgr_utils-0.0.143 lib/markdown/ul.rb
tbpgr_utils-0.0.142 lib/markdown/ul.rb
tbpgr_utils-0.0.141 lib/markdown/ul.rb
tbpgr_utils-0.0.140 lib/markdown/ul.rb
tbpgr_utils-0.0.139 lib/markdown/ul.rb
tbpgr_utils-0.0.138 lib/markdown/ul.rb
tbpgr_utils-0.0.137 lib/markdown/ul.rb
tbpgr_utils-0.0.136 lib/markdown/ul.rb
tbpgr_utils-0.0.135 lib/markdown/ul.rb
tbpgr_utils-0.0.134 lib/markdown/ul.rb
tbpgr_utils-0.0.133 lib/markdown/ul.rb
tbpgr_utils-0.0.132 lib/markdown/ul.rb