Class: PublishMyData::DataCube::Dimension
- Inherits:
-
Object
- Object
- PublishMyData::DataCube::Dimension
- Includes:
- CubeResults
- Defined in:
- app/models/publish_my_data/data_cube/dimension.rb
Constant Summary collapse
- PAGE_SIZE =
5000
Instance Attribute Summary collapse
-
#cube ⇒ Object
readonly
Returns the value of attribute cube.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(uri, cube, label = nil) ⇒ Dimension
constructor
A new instance of Dimension.
- #size ⇒ Object
-
#values ⇒ Object
get all the possible values (uris and labels) for this dimension in the dataset passed in.
Methods included from CubeResults
#loop_and_page_sparql_query, #uris_and_labels_only
Constructor Details
#initialize(uri, cube, label = nil) ⇒ Dimension
Returns a new instance of Dimension.
12 13 14 15 16 |
# File 'app/models/publish_my_data/data_cube/dimension.rb', line 12 def initialize(uri, cube, label = nil) @uri = uri @cube = cube @label = label end |
Instance Attribute Details
#cube ⇒ Object (readonly)
Returns the value of attribute cube.
7 8 9 |
# File 'app/models/publish_my_data/data_cube/dimension.rb', line 7 def cube @cube end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
8 9 10 |
# File 'app/models/publish_my_data/data_cube/dimension.rb', line 8 def label @label end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'app/models/publish_my_data/data_cube/dimension.rb', line 6 def uri @uri end |
Instance Method Details
#size ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'app/models/publish_my_data/data_cube/dimension.rb', line 26 def size # don't get labels and don't paginate. sparql = values_sparql({labels:false}) sq = Tripod::SparqlQuery.new(sparql) count_sparql = sq.as_count_query_str result = Tripod::SparqlClient::Query.select(count_sparql) result[0]["tripod_count_var"]["value"].to_i end |
#values ⇒ Object
get all the possible values (uris and labels) for this dimension in the dataset passed in. paginates internally if necessary.
20 21 22 23 24 |
# File 'app/models/publish_my_data/data_cube/dimension.rb', line 20 def values sparql = values_sparql(labels:true) results = loop_and_page_sparql_query(sparql) # by default this tries 5000 rows at a time. uris_and_labels_only(results) end |