Class: Xml2Go::Field
- Inherits:
-
Object
- Object
- Xml2Go::Field
- Defined in:
- lib/xml2go/struct.rb
Overview
represents member variables
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
-
#xml_tag ⇒ Object
Returns the value of attribute xml_tag.
Instance Method Summary collapse
-
#initialize(name, type, xml_tag, value) ⇒ Field
constructor
A new instance of Field.
- #to_const ⇒ Object
- #to_declaration ⇒ Object
- #to_s ⇒ Object
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
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/xml2go/struct.rb', line 6 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/xml2go/struct.rb', line 6 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/xml2go/struct.rb', line 6 def value @value end |
#xml_tag ⇒ Object
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_const ⇒ Object
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_declaration ⇒ Object
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_s ⇒ Object
16 17 18 |
# File 'lib/xml2go/struct.rb', line 16 def to_s "#{@name} #{@type} `xml:\"#{@xml_tag}\"`" end |