Class: Study
- Inherits:
-
NesstarObject
- Object
- NesstarObject
- Study
- Includes:
- VariableContainer
- Defined in:
- lib/nesstar-api/study.rb
Overview
Represents a study
Constant Summary collapse
- NSDSTAT =
"NSDSTAT"- SAS =
"SAS"- SPSS =
"SPSS"- SPSSPORT =
"SPSSPORT"- STATA =
"STATA"- STATA6 =
"STATA6"- STATA7 =
"STATA7"
Instance Attribute Summary collapse
-
#abstract ⇒ Object
readonly
Returns the value of attribute abstract.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #correlate ⇒ Object
-
#download(format, variables = [], case_subset = nil) ⇒ Object
Downloads the study (or parts of it) in different file formats.
-
#initialize(data) ⇒ Study
constructor
A new instance of Study.
- #regress ⇒ Object
-
#tabulate(options) ⇒ Object
Returns a cross tabulation on this study.
Methods included from VariableContainer
#get_variable_groups, #get_variables
Constructor Details
#initialize(data) ⇒ Study
Returns a new instance of Study.
22 23 24 25 26 27 |
# File 'lib/nesstar-api/study.rb', line 22 def initialize(data) @id = data['id'] @name = data['name'] @abstract = data['abstract'] @last_update = data['updatedTimeStamp'] end |
Instance Attribute Details
#abstract ⇒ Object (readonly)
Returns the value of attribute abstract.
10 11 12 |
# File 'lib/nesstar-api/study.rb', line 10 def abstract @abstract end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/nesstar-api/study.rb', line 10 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/nesstar-api/study.rb', line 10 def name @name end |
Instance Method Details
#correlate ⇒ Object
50 51 |
# File 'lib/nesstar-api/study.rb', line 50 def correlate end |
#download(format, variables = [], case_subset = nil) ⇒ Object
Downloads the study (or parts of it) in different file formats.
The file will be a zip file containing one or more files depending on the requested format.
The format parameter should be one of the constants in this class.
To only download some variables, supply a list of the variables you wish.
The download can be further refined using a case subset. See nesstar-dev.nsd.uib.no/javadoc/com.nesstar/nesstar-api/0.6.5/com/nesstar/api/subset/CaseSubset.html#compile for more information.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/nesstar-api/study.rb', line 66 def download(format, variables = [], case_subset = nil) path = "study/#{@id}/download" query_string = ["format=" + format] query_string += collect_list(variables, "var", :id) query_string.push("caseSubset=" + case_subset) unless case_subset.nil? path += "?" + query_string.join('&') get_binary(path) do | data | if block_given? yield(data) else file = Tempfile.new("#{@name}.#{format}") file.write(data) file.close return file end end end |
#regress ⇒ Object
53 54 |
# File 'lib/nesstar-api/study.rb', line 53 def regress end |
#tabulate(options) ⇒ Object
Returns a cross tabulation on this study
The options parameter holds the following data:
-
breakVars- A list of variable objects -
msrVar- The measure variable, if any -
msrType- A list of measure types to use. Valid types are MEAN, MEDIAN, STDDEV, MIN, MAX, SUM, COUNT, CI95MIN, CI95MAX, CI99MIN, CI99MAX, Q1, Q3, WHISKER_LO, WHISKER_HI, SUM_SQUARES, SE_MEAN -
casesubset- A subset expression to limit the categories to include. Documentation on expressions is found here: nesstar-dev.nsd.uib.no/javadoc/com.nesstar/nesstar-api/0.6.5/com/nesstar/api/subset/CaseSubset.html#compile
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/nesstar-api/study.rb', line 38 def tabulate() path = "study/#{@id}/tabulate/" query_string = prepare_query_string_for_tabulation if query_string.length > 0 path += "?" + query_string.join('&') end tabulation = get_values path Tabulation.new tabulation, end |