Class: BlifUtils::AST::Model
- Inherits:
-
Object
- Object
- BlifUtils::AST::Model
- Defined in:
- lib/blifutils/ast.rb
Instance Attribute Summary collapse
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#isBlackBox ⇒ Object
readonly
Returns the value of attribute isBlackBox.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, header, commands = []) ⇒ Model
constructor
A new instance of Model.
- #pretty_print(indent) ⇒ Object
Constructor Details
#initialize(name, header, commands = []) ⇒ Model
Returns a new instance of Model.
42 43 44 45 46 47 48 49 50 51 |
# 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 |
Instance Attribute Details
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
40 41 42 |
# File 'lib/blifutils/ast.rb', line 40 def commands @commands end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
40 41 42 |
# File 'lib/blifutils/ast.rb', line 40 def header @header end |
#isBlackBox ⇒ Object (readonly)
Returns the value of attribute isBlackBox.
40 41 42 |
# File 'lib/blifutils/ast.rb', line 40 def isBlackBox @isBlackBox end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
40 41 42 |
# File 'lib/blifutils/ast.rb', line 40 def name @name end |
Instance Method Details
#pretty_print(indent) ⇒ Object
53 54 55 56 57 58 |
# 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 |