class Gumdrop::Util::YamlDoc
Attributes
body[R]
data[R]
Public Class Methods
new(source, extended_support=false)
click to toggle source
# File lib/gumdrop/util/yaml_doc.rb, line 11 def initialize(source, extended_support=false) @data= {} @body= source @extended_support= extended_support _compile end
Public Instance Methods
is_yamldoc?()
click to toggle source
# File lib/gumdrop/util/yaml_doc.rb, line 18 def is_yamldoc? @is_yamldoc end
Private Instance Methods
_compile()
click to toggle source
# File lib/gumdrop/util/yaml_doc.rb, line 24 def _compile source = @body || "" if source =~ PARSER yaml = $2.strip @body = source.sub($1, '') @data= YAML.load(yaml) @is_yamldoc= true else @data={ 'content' => @body } if @extended_support @is_yamldoc= false end return unless @extended_support or !@is_yamldoc content_set= false @data.each_pair do |key, value| if value == '_YAMLDOC_' @data[key]= @body content_set= true end end @data['content']= @body unless content_set end