Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/regexrx2md/string.rb

Overview

String helpers

Instance Method Summary collapse

Instance Method Details

#indentObject



9
10
11
12
13
# File 'lib/regexrx2md/string.rb', line 9

def indent
  out = ''
  split("\n").each { |line| out += "    #{line}\n" }
  out
end

#snippet_noteObject



19
20
21
# File 'lib/regexrx2md/string.rb', line 19

def snippet_note
  split("\n").map { |line| "> #{line}" }.join("\n")
end

#to_jsObject



15
16
17
# File 'lib/regexrx2md/string.rb', line 15

def to_js
  gsub(%r{(?mi)(?<!\\)/}, '\/')
end

#unpackObject



5
6
7
# File 'lib/regexrx2md/string.rb', line 5

def unpack
  [self].pack('H*').gsub(/\r/, "\n")
end