Sha256: f52f01fcbd4066792c0fb78cb046023104856756dd5d053abcf082cf9f2d5d99
Contents?: true
Size: 719 Bytes
Versions: 1
Compression:
Stored size: 719 Bytes
Contents
# encoding: utf-8 class MarkdownString # Return markdown heading level1-6 from text # # === Example # # case list # # MarkdownString.ol(%w{a b c}) # # resolt # # 1. a # 1. b # 1. c # # case not list # # MarkdownString.ol("test") # => "test" # # case nil list # # MarkdownString.ol([nil, nil]) # # resolt # # 1. # 1. # # case empty list # # MarkdownString.ol([]) # => "" # def self.ol(list) return list unless list.is_a?(Array) return '' if list.empty? list.reduce([]) do |ret, elm| elm = '' if elm.nil? ret << "1. #{elm}" ret end.join("\n") + "\n" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tbpgr_utils-0.0.108 | lib/markdown/ol.rb |