Class: AutoC::Module::Header

Inherits:
File
  • Object
show all
Defined in:
lib/autoc/code.rb

Instance Attribute Summary collapse

Attributes inherited from File

#entities

Instance Method Summary collapse

Methods inherited from File

#<<, #generate

Constructor Details

#initialize(*args) ⇒ Header

Returns a new instance of Header.



164
165
166
167
168
# File 'lib/autoc/code.rb', line 164

def initialize(*args)
  super
  @file_name = "#{@module.name.downcase}_auto.h"
  @guard_macro = "#{@module.name.upcase}_AUTO_H"
end

Instance Attribute Details

#file_nameObject (readonly)

Returns the value of attribute file_name.



162
163
164
# File 'lib/autoc/code.rb', line 162

def file_name
  @file_name
end

Instance Method Details

#new_streamObject



170
171
172
# File 'lib/autoc/code.rb', line 170

def new_stream
  ::File.new(@file_name, "w")
end

#write(stream) ⇒ Object



174
175
176
177
178
179
180
181
182
183
184
# File 'lib/autoc/code.rb', line 174

def write(stream)
  stream << %$
    /* AUTOMATICALLY GENERATED HEADER FILE. DO NOT MODIFY. */
    #ifndef #{@guard_macro}
    #define #{@guard_macro}
  $
  AutoC.priority_sort(entities).each {|e| e.write_intf(stream)}
  stream << %$
    #endif
  $
end