Module: YAML

Defined in:
lib/chisel/ruby/yaml.rb

Defined Under Namespace

Modules: Syck

Class Method Summary collapse

Class Method Details

.header_string(string) ⇒ Object



9
10
11
12
13
# File 'lib/chisel/ruby/yaml.rb', line 9

def YAML.header_string(string)
	matches = string.match(/---\r*\n(.*)\r*\n---/m)
	return '' unless matches and matches.size > 1
	matches[1]
end

.load_header(string) ⇒ Object



15
16
17
18
19
# File 'lib/chisel/ruby/yaml.rb', line 15

def YAML.load_header(string)
	header_string = YAML.header_string(string)
	return {} if header_string == ''
	YAML.load(header_string)
end

.remove_header(string) ⇒ Object



3
4
5
6
7
# File 'lib/chisel/ruby/yaml.rb', line 3

def YAML.remove_header(string)
	matches = string.match(/---\r*\n(.*)\n---\r*\n(.*)/m)
	return string unless matches and matches.size > 2
	matches[2]
end