Class: RubyHToGo::TypeDefinition
- Inherits:
-
Object
- Object
- RubyHToGo::TypeDefinition
- Extended by:
- Forwardable
- Defined in:
- _tools/ruby_h_to_go/lib/ruby_h_to_go/type_definition.rb
Overview
Proxy class for generating go type
Instance Method Summary collapse
- #generate_go_content ⇒ String
-
#initialize(definition:) ⇒ TypeDefinition
constructor
A new instance of TypeDefinition.
-
#write_go_file(dist_dir) ⇒ Object
Write definition as go file.
Constructor Details
#initialize(definition:) ⇒ TypeDefinition
Returns a new instance of TypeDefinition.
11 12 13 |
# File '_tools/ruby_h_to_go/lib/ruby_h_to_go/type_definition.rb', line 11 def initialize(definition:) @definition = definition end |
Instance Method Details
#generate_go_content ⇒ String
28 29 30 31 32 33 34 35 36 |
# File '_tools/ruby_h_to_go/lib/ruby_h_to_go/type_definition.rb', line 28 def generate_go_content go_type_name = GoUtil.snake_to_camel(name) <<~GO // #{go_type_name} is a type for passing `C.#{name}` in and out of package type #{go_type_name} C.#{name} GO end |
#write_go_file(dist_dir) ⇒ Object
Write definition as go file
17 18 19 20 21 22 23 24 25 |
# File '_tools/ruby_h_to_go/lib/ruby_h_to_go/type_definition.rb', line 17 def write_go_file(dist_dir) go_file_path = File.join(dist_dir, "type_generated.go") GoUtil.generate_initial_go_file(go_file_path) File.open(go_file_path, "a") do |f| f.write(generate_go_content) end end |