Class: SPSS::Dictionary::Variable
Instance Attribute Summary collapse
-
#aligment ⇒ Object
Returns the value of attribute aligment.
-
#decimals ⇒ Object
Returns the value of attribute decimals.
-
#display_width ⇒ Object
Returns the value of attribute display_width.
-
#label ⇒ Object
Returns the value of attribute label.
-
#labelset ⇒ Object
Returns the value of attribute labelset.
-
#measurement_level ⇒ Object
Returns the value of attribute measurement_level.
-
#missing_values ⇒ Object
Returns the value of attribute missing_values.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
-
#type_format ⇒ Object
Returns the value of attribute type_format.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(config = {}) ⇒ Variable
constructor
A new instance of Variable.
- #to_spss ⇒ Object
- #to_xml ⇒ Object
Methods inherited from Element
#add, #init_with, #parse_elements
Constructor Details
#initialize(config = {}) ⇒ Variable
Returns a new instance of Variable.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/spss.rb', line 80 def initialize(config={}) super @@var_number||=1 init_with({ :aligment => "left", :display_width => 8, :label => "Variable #{@@var_number}", :measurement_level => "SCALE", :name => "var#{@@var_number}", :type => 0, :decimals => 2, :width => 10, :type_format => "F", :labelset => nil }) init_with config @missing_values=[] @@var_number+=1 end |
Instance Attribute Details
#aligment ⇒ Object
Returns the value of attribute aligment.
79 80 81 |
# File 'lib/spss.rb', line 79 def aligment @aligment end |
#decimals ⇒ Object
Returns the value of attribute decimals.
79 80 81 |
# File 'lib/spss.rb', line 79 def decimals @decimals end |
#display_width ⇒ Object
Returns the value of attribute display_width.
79 80 81 |
# File 'lib/spss.rb', line 79 def display_width @display_width end |
#label ⇒ Object
Returns the value of attribute label.
79 80 81 |
# File 'lib/spss.rb', line 79 def label @label end |
#labelset ⇒ Object
Returns the value of attribute labelset.
79 80 81 |
# File 'lib/spss.rb', line 79 def labelset @labelset end |
#measurement_level ⇒ Object
Returns the value of attribute measurement_level.
79 80 81 |
# File 'lib/spss.rb', line 79 def measurement_level @measurement_level end |
#missing_values ⇒ Object
Returns the value of attribute missing_values.
79 80 81 |
# File 'lib/spss.rb', line 79 def missing_values @missing_values end |
#name ⇒ Object
Returns the value of attribute name.
79 80 81 |
# File 'lib/spss.rb', line 79 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
79 80 81 |
# File 'lib/spss.rb', line 79 def type @type end |
#type_format ⇒ Object
Returns the value of attribute type_format.
79 80 81 |
# File 'lib/spss.rb', line 79 def type_format @type_format end |
#width ⇒ Object
Returns the value of attribute width.
79 80 81 |
# File 'lib/spss.rb', line 79 def width @width end |
Instance Method Details
#to_spss ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/spss.rb', line 104 def to_spss out=<<HERE VARIABLE LABELS #{@name} '#{label}' . VARIABLE ALIGMENT #{@name} (#{@aligment.upcase}) . VARIABLE WIDTH #{@name} (#{@display_width}) . VARIABLE LEVEL #{@name} (#{@measurement_level.upcase}) . HERE if !@labelset.nil? out << "VALUE LABELS #{@name} "+labelset.parse_spss()+" ." end if @missing_values.size>0 out << "MISSING VALUES #{@name} ("+@missing_values.collect{|m| m.data}.join(",")+") ." end out end |
#to_xml ⇒ Object
99 100 101 102 103 |
# File 'lib/spss.rb', line 99 def to_xml labelset_s=(@labelset.nil?) ? "":"\n"+@labelset.parse_xml(@name) missing_values=(@missing_values.size>0) ? @missing_values.collect {|m| m.to_xml}.join("\n"):"" "<variable aligment='#{@aligment}' displayWidth='#{@display_width}' label='#{@label}' measurementLevel='#{@measurement_level}' name='#{@name}' type='#{@type}'>\n<variableFormat decimals='#{@decimals}' width='#{@width}' type='#{@type_format}' />\n"+parse_elements(:to_xml)+missing_values+"</variable>"+labelset_s end |