Class: RDF::Tabular::TableGroup
- Defined in:
- lib/rdf/tabular/metadata.rb
Constant Summary collapse
- PROPERTIES =
{ :@id => :link, :@type => :atomic, notes: :array, tables: :array, tableSchema: :object, tableDirection: :atomic, dialect: :object, transformations: :array, }.freeze
- DEFAULTS =
{ tableDirection: "auto".freeze, }.freeze
- REQUIRED =
[:tables].freeze
Constants inherited from Metadata
Metadata::DATATYPES, Metadata::INHERITED_DEFAULTS, Metadata::INHERITED_PROPERTIES, Metadata::LOCAL_CONTEXT, Metadata::NAME_SYNTAX
Instance Attribute Summary
Attributes inherited from Metadata
#filenames, #id, #object, #parent, #url
Instance Method Summary collapse
-
#each_table {|Table| ... } ⇒ Object
Iterate over all tables.
-
#for_table(url) ⇒ Table
Return the metadata for a specific table, re-basing context as necessary.
-
#has_annotations? ⇒ Boolean
Does the Metadata or any descendant have any common properties.
-
#to_atd ⇒ Object
Return Annotated Table Group representation.
Methods inherited from Metadata
#==, #[], #[]=, #base, #common_properties, #context, #datatype=, #default_value, #describes_file?, #dialect, #dialect=, #each, #each_row, for_input, #initialize, #inspect, #normalize!, #normalize_jsonld, open, #root, #set_array_value, #set_nl, #set_property, site_wide_config, #tableSchema=, #tables=, #to_json, #transformations=, #type, #valid?, #valid_natural_language_property?, #validate, #validate!, #verify_compatible!
Constructor Details
This class inherits a constructor from RDF::Tabular::Metadata
Instance Method Details
#each_table {|Table| ... } ⇒ Object
Iterate over all tables
1345 1346 1347 1348 1349 |
# File 'lib/rdf/tabular/metadata.rb', line 1345 def each_table tables.map(&:url).each do |url| yield for_table(url) end end |
#for_table(url) ⇒ Table
Return the metadata for a specific table, re-basing context as necessary
1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 |
# File 'lib/rdf/tabular/metadata.rb', line 1356 def for_table(url) # If there are no tables, assume there's one for this table #self.tables ||= [Table.new(url: url)] if table = Array(tables).detect {|t| t.url == url} # Set document base for this table for resolving URLs table.instance_variable_set(:@context, context.dup) table.context.base = url table end end |
#has_annotations? ⇒ Boolean
Does the Metadata or any descendant have any common properties
1338 1339 1340 |
# File 'lib/rdf/tabular/metadata.rb', line 1338 def has_annotations? super || tables.any? {|t| t.has_annotations? } end |
#to_atd ⇒ Object
Return Annotated Table Group representation
1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 |
# File 'lib/rdf/tabular/metadata.rb', line 1368 def to_atd object.inject({ "@id" => (id.to_s if id), "@type" => "AnnotatedTableGroup", "tables" => Array(self.tables).map(&:to_atd) }) do |memo, (k, v)| memo[k.to_s] ||= v memo end.delete_if {|k,v| v.nil? || v.is_a?(Metadata) || k.to_s == "@context"} end |