class BlifUtils::AST::Model

Attributes

commands[R]
header[R]
isBlackBox[R]
name[R]

Public Class Methods

new(name, header, commands = []) click to toggle source
# File lib/blifutils/ast.rb, line 42
def initialize (name, header, commands = [])
        @name = name
        @header = header
        @commands = commands
        @isBlackBox = not(@commands.index{|command| command.class == AST::BlackBox}.nil?)
        if @isBlackBox and not(@commands.reject{|command| command.class == AST::BlackBox}.empty?) then
                STDERR.puts "WARNING: Blackbox \"#{@name}\" contains non blackbox commands"
                @commands = @commands.reject{|command| command.class == AST::BlackBox}.uniq
        end
end

Public Instance Methods

pretty_print(indent) click to toggle source
# File lib/blifutils/ast.rb, line 53
def pretty_print (indent)
        str = '    '*indent + "#{@isBlackBox ? 'Black box' : 'Model'}:\n" + '    '*(indent+1) + "Name:    \"#{@name}\"\n"
        @header.each{|headEl| str += headEl.pretty_print(indent+1)}
        @commands.each{|com| str += com.pretty_print(indent+1)} unless @isBlackBox
        return str
end