Class: Xml2Go::Field

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

Overview

represents member variables

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, xml_tag, value) ⇒ Field

Returns a new instance of Field.



8
9
10
11
12
13
14
# File 'lib/xml2go/struct.rb', line 8

def initialize(name, type, xml_tag, value)
  @name = name
  @type = type
  @xml_tag = xml_tag
  @value = value
  @const_name = Xml2Go::get_const_name(@name)
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/xml2go/struct.rb', line 6

def name
  @name
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/xml2go/struct.rb', line 6

def type
  @type
end

#valueObject

Returns the value of attribute value.



6
7
8
# File 'lib/xml2go/struct.rb', line 6

def value
  @value
end

#xml_tagObject

Returns the value of attribute xml_tag.



6
7
8
# File 'lib/xml2go/struct.rb', line 6

def xml_tag
  @xml_tag
end

Instance Method Details

#to_constObject



25
26
27
28
29
30
# File 'lib/xml2go/struct.rb', line 25

def to_const
  if !value.nil? then
    return "#{@const_name} = \"#{@value}\""
  end
  return ""
end

#to_declarationObject



20
21
22
23
# File 'lib/xml2go/struct.rb', line 20

def to_declaration
  value = @value.nil? ? Xml2Go::low(@name) : @const_name
  "#{@name}: #{value},"
end

#to_sObject



16
17
18
# File 'lib/xml2go/struct.rb', line 16

def to_s
  "#{@name} #{@type} `xml:\"#{@xml_tag}\"`"
end