Class: FFI::Generator::Structure
- Defined in:
- lib/generator/generator.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Node
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = { }) ⇒ Structure
constructor
A new instance of Structure.
- #to_s ⇒ Object
Methods inherited from Node
Constructor Details
#initialize(params = { }) ⇒ Structure
Returns a new instance of Structure.
211 212 213 214 |
# File 'lib/generator/generator.rb', line 211 def initialize(params = { }) super @name = self.class.camelcase(@symname) end |
Class Method Details
.camelcase(name) ⇒ Object
208 209 210 |
# File 'lib/generator/generator.rb', line 208 def self.camelcase(name) name.gsub(/^\w|\_\w/).each {|c| c.upcase }.delete('_') end |
Instance Method Details
#to_s ⇒ Object
215 216 217 218 219 220 |
# File 'lib/generator/generator.rb', line 215 def to_s fields_str = fields.inject("") do |str, f| str << @indent_str + ' ' * 9 << f.join(', ') << ",\n" end code = klass_string + @indent_str + " layout(\n" + fields_str.chomp.chomp(',') + "\n" + @indent_str + " )\n" + @indent_str + "end\n" end |