Class: Raml::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/raml/node.rb

Direct Known Subclasses

PropertiesNode, Reference, ValueNode

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, parent) ⇒ Node

Returns a new instance of Node.



34
35
36
37
# File 'lib/raml/node.rb', line 34

def initialize(name, parent)
  @name   = name
  @parent = parent
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



29
30
31
# File 'lib/raml/node.rb', line 29

def name
  @name
end

#parentRaml::Node

Returns the node’s parent.

Returns:



32
33
34
# File 'lib/raml/node.rb', line 32

def parent
  @parent
end

Class Method Details

.relative_path(file) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/raml/node.rb', line 12

def relative_path(file)
  File.join(
    *File.dirname(__FILE__).
      split(File::SEPARATOR).
      reverse.
      drop_while { |p| p != 'lib' }.
      drop(1).
      reverse,
    'templates',
    file
  )
end

Instance Method Details

#documentString

Returns HTML documenting the node and child nodes.

Returns:

  • (String)

    HTML documentation.



41
42
43
44
45
46
47
48
# File 'lib/raml/node.rb', line 41

def document
  if doc_template
    self.doc_template_compiled ||= Slim::Template.new(doc_template, format: :html5, pretty: true)
    doc_template_compiled.render self
  else
    nil
  end
end