class Xml2Go::Struct
class representing a Go struct
Attributes
fields[RW]
type[RW]
Public Class Methods
new(type)
click to toggle source
# File lib/xml2go/struct.rb, line 38 def initialize(type) @type = type @fields = {} end
Public Instance Methods
add_field(var_name, type, xml_tag, value=nil)
click to toggle source
adds member variable to struct
# File lib/xml2go/struct.rb, line 44 def add_field(var_name, type, xml_tag, value=nil) @fields[var_name] = Field.new(var_name, type, xml_tag, value) end
delete_field(var_name)
click to toggle source
adds member variable to struct
# File lib/xml2go/struct.rb, line 49 def delete_field(var_name) @fields.delete(var_name) end
get_consts()
click to toggle source
# File lib/xml2go/struct.rb, line 68 def get_consts consts_string = @fields.values.map{ |v| v.to_const} "// #{@type} info \n" << consts_string.join("\n") end
to_declaration()
click to toggle source
# File lib/xml2go/struct.rb, line 61 def to_declaration fields_string = @fields.values.map { |v| v.to_declaration} "#{Xml2Go::low(@type)} := #{@type} { #{fields_string.join("\n")} }" end
to_s()
click to toggle source
# File lib/xml2go/struct.rb, line 53 def to_s fields_string = @fields.values.join("\n") "type #{@type} struct {\n #{fields_string} } " end