Class: String
Instance Method Summary collapse
- #indent(options = {}) ⇒ Object
- #indent_with_wrap(options = {}) ⇒ Object
- #wrap(options = {}) ⇒ Object
Methods included from ForceArray
Instance Method Details
#indent(options = {}) ⇒ Object
1054 1055 1056 1057 |
# File 'lib/liquidoc.rb', line 1054 def indent = {} spaces = " " * .fetch(:spaces, 4) self.gsub(/^/, spaces).gsub(/^\s*$/, '') end |
#indent_with_wrap(options = {}) ⇒ Object
1059 1060 1061 1062 1063 1064 |
# File 'lib/liquidoc.rb', line 1059 def indent_with_wrap = {} spaces = .fetch(:spaces, 4) width = .fetch(:width, 80) width = width > spaces ? width - spaces : 1 self.wrap(width: width).indent(spaces: spaces) end |
#wrap(options = {}) ⇒ Object
1046 1047 1048 1049 1050 1051 1052 |
# File 'lib/liquidoc.rb', line 1046 def wrap = {} width = .fetch(:width, 76) commentchar = .fetch(:commentchar, '') self.strip.split("\n").collect do |line| line.length > width ? line.gsub(/(.{1,#{width}})(\s+|$)/, "\\1\n#{commentchar}") : line end.map(&:strip).join("\n#{commentchar}") end |