Class: RedSnow::NamedBlueprintNode Abstract

Inherits:
BlueprintNode show all
Defined in:
lib/redsnow/blueprint.rb

Overview

This class is abstract.

Blueprint AST node with name && description associated

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#descriptionString

description of the node

Returns:

  • (String)

    the current value of description



32
33
34
# File 'lib/redsnow/blueprint.rb', line 32

def description
  @description
end

#nameString

name of the node

Returns:

  • (String)

    the current value of name



32
33
34
# File 'lib/redsnow/blueprint.rb', line 32

def name
  @name
end

Instance Method Details

#ensure_description_newlines(buffer) ⇒ Object

Ensure the input string buffer ends with two newlines.

Parameters:

  • buffer (String)

    a buffer to check If the buffer does not ends with two newlines the newlines are added.



40
41
42
43
44
45
46
47
48
# File 'lib/redsnow/blueprint.rb', line 40

def ensure_description_newlines(buffer)
  return if description.empty?

  if description[-1, 1] != '\n'
    buffer << '\n\n'
  elsif description.length > 1 && description[-2, 1] != '\n'
    buffer << '\n'
  end
end