class MatterCompiler::Blueprint

Top-level Blueprint AST node

represents 'blueprint section'

@attr metadata [Metadata] tool-specific metadata collection or nil @attr resource_groups [Array<ResourceGroup>] array of blueprint resource groups

Constants

SUPPORTED_VERSIONS
VERSION_KEY

Attributes

metadata[RW]
resource_groups[RW]

Public Instance Methods

load_ast!(ast) click to toggle source
# File lib/matter_compiler/blueprint.rb, line 554
def load_ast!(ast)
  super(ast)
  
  # Load Metadata
  unless ast[:metadata].blank?
    @metadata = Metadata.new(ast[:metadata])
  end
  
  # Load Resource Groups
  unless ast[:resourceGroups].blank?
    @resource_groups = Array.new
    ast[:resourceGroups].each { |group_ast| @resource_groups << ResourceGroup.new(group_ast) }
  end
end
serialize(set_blueprint_format = false) click to toggle source
# File lib/matter_compiler/blueprint.rb, line 569
def serialize(set_blueprint_format = false)
  buffer = ""
  
  if set_blueprint_format
    buffer << "FORMAT: 1A\n"
    if @metadata
      buffer << "#{@metadata.serialize(0, [:FORMAT])}"
    else
      buffer << "\n"
    end
  else
    buffer << "#{@metadata.serialize}" unless @metadata.nil?
  end

  buffer << "# #{@name}\n" unless @name.blank?
  buffer << "#{@description}" unless @description.blank?
  ensure_description_newlines(buffer)

  @resource_groups.each { |group| buffer << group.serialize } unless @resource_groups.nil?
  buffer
end