Class: Variable
- Inherits:
-
NesstarObject
- Object
- NesstarObject
- Variable
- Defined in:
- lib/nesstar-api/variable.rb
Overview
Represents a variable in a Study.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#continuous? ⇒ Boolean
Indicates whether the variable is continuous.
-
#discrete? ⇒ Boolean
Indicates whether the variable is discrete.
-
#get_categories ⇒ Object
Returns a list of categories in this variable.
-
#initialize(data, eager = false) ⇒ Variable
constructor
A new instance of Variable.
-
#weighted? ⇒ Boolean
Indicates whether this is a weight variable.
Constructor Details
#initialize(data, eager = false) ⇒ Variable
Returns a new instance of Variable.
9 10 11 12 13 14 15 16 |
# File 'lib/nesstar-api/variable.rb', line 9 def initialize(data, eager = false) @id = data['id'] @name = data['name'] @label = data['label'] if eager end end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/nesstar-api/variable.rb', line 7 def id @id end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
7 8 9 |
# File 'lib/nesstar-api/variable.rb', line 7 def label @label end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/nesstar-api/variable.rb', line 7 def name @name end |
Instance Method Details
#continuous? ⇒ Boolean
Indicates whether the variable is continuous.
26 27 28 |
# File 'lib/nesstar-api/variable.rb', line 26 def continuous? ['intrvl'] == 'continuous' end |
#discrete? ⇒ Boolean
Indicates whether the variable is discrete.
20 21 22 |
# File 'lib/nesstar-api/variable.rb', line 20 def discrete? ['intrvl'] == 'discrete' end |
#get_categories ⇒ Object
Returns a list of categories in this variable
38 39 40 41 42 |
# File 'lib/nesstar-api/variable.rb', line 38 def get_categories ['catgry'].collect do | category | Category.new category end end |
#weighted? ⇒ Boolean
Indicates whether this is a weight variable
32 33 34 |
# File 'lib/nesstar-api/variable.rb', line 32 def weighted? ['wgt'] end |