Class: Ruco::Identifier
- Inherits:
-
Object
- Object
- Ruco::Identifier
- Defined in:
- lib/ruco.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#prodset ⇒ Object
Returns the value of attribute prodset.
Instance Method Summary collapse
- #generate(indent = 0) ⇒ Object
-
#initialize(name) ⇒ Identifier
constructor
A new instance of Identifier.
Constructor Details
#initialize(name) ⇒ Identifier
Returns a new instance of Identifier.
28 29 30 31 |
# File 'lib/ruco.rb', line 28 def initialize(name) @name = name @prodset = prodset end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
27 28 29 |
# File 'lib/ruco.rb', line 27 def name @name end |
#prodset ⇒ Object
Returns the value of attribute prodset.
27 28 29 |
# File 'lib/ruco.rb', line 27 def prodset @prodset end |
Instance Method Details
#generate(indent = 0) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/ruco.rb', line 33 def generate(indent=0) code = "production->#{name.downcase} = #{name.downcase};" if @prodset[name][:count] > 1 code = "production->#{name.downcase.pluralize}.push_back(#{name.downcase});" end "#{("\t"*indent)}#{name}<#{name.downcase}> (. #{code} .)" end |