Class: IdVar

Inherits:
Object
  • Object
show all
Defined in:
lib/erbpp.rb

Overview


Constant Summary collapse

DEFS =
[]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, name, var = nil) ⇒ IdVar

Returns a new instance of IdVar.



124
125
126
127
128
129
# File 'lib/erbpp.rb', line 124

def initialize(parent,name,var=nil)
  @name = name
  var = name if var.nil?
  @id_var = "id_"+var.gsub(/\?/,"_p").gsub(/\!/,"_bang")
  DEFS.push(self)
end

Class Method Details

.assignmentObject



137
138
139
140
141
# File 'lib/erbpp.rb', line 137

def self.assignment
  DEFS.map do |x|
    x.id_assign
  end
end

.declarationObject



131
132
133
134
135
# File 'lib/erbpp.rb', line 131

def self.declaration
  DEFS.map do |x|
    x.id_decl
  end
end

Instance Method Details

#id_assignObject



120
121
122
# File 'lib/erbpp.rb', line 120

def id_assign
  "#{@id_var} = rb_intern(\"#{@name}\");"
end

#id_declObject



116
117
118
# File 'lib/erbpp.rb', line 116

def id_decl
  "static ID #{@id_var};"
end