Class: Madman::YAMLDoc

Inherits:
Object
  • Object
show all
Defined in:
lib/madman/yamldoc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(yaml, title: nil) ⇒ YAMLDoc

Returns a new instance of YAMLDoc.



11
12
13
14
# File 'lib/madman/yamldoc.rb', line 11

def initialize(yaml, title: nil)
  @yaml = yaml
  @title = title
end

Instance Attribute Details

#titleObject (readonly)

Returns the value of attribute title.



9
10
11
# File 'lib/madman/yamldoc.rb', line 9

def title
  @title
end

#yamlObject (readonly)

Returns the value of attribute yaml.



9
10
11
# File 'lib/madman/yamldoc.rb', line 9

def yaml
  @yaml
end

Instance Method Details

#renderObject



16
17
18
# File 'lib/madman/yamldoc.rb', line 16

def render
  slim.render self
end

#slimObject



24
25
26
# File 'lib/madman/yamldoc.rb', line 24

def slim
  @slim ||= Slim::Template.new template, slim_options
end

#slim_optionsObject



28
29
30
# File 'lib/madman/yamldoc.rb', line 28

def slim_options
  { pretty: true, disable_escape: true }
end

#templateObject



20
21
22
# File 'lib/madman/yamldoc.rb', line 20

def template
  File.expand_path '../views/yamldoc.slim', __dir__
end

#treeObject



32
33
34
# File 'lib/madman/yamldoc.rb', line 32

def tree
  @tree ||= tree!
end