Class: RDF::Tabular::TableGroup
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/rdf-tabular-52804f52e930/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
Constants included from Util::Logger
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!
Methods included from Util::Logger
#log_debug, #log_depth, #log_error, #log_fatal, #log_info, #log_recover, #log_recovering?, #log_statistics, #log_warn, #logger
Constructor Details
This class inherits a constructor from RDF::Tabular::Metadata
Instance Method Details
#each_table {|Table| ... } ⇒ Object
Iterate over all tables
1347 1348 1349 1350 1351 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-tabular-52804f52e930/lib/rdf/tabular/metadata.rb', line 1347 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
1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-tabular-52804f52e930/lib/rdf/tabular/metadata.rb', line 1358 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
1340 1341 1342 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-tabular-52804f52e930/lib/rdf/tabular/metadata.rb', line 1340 def has_annotations? super || tables.any? {|t| t.has_annotations? } end |
#to_atd ⇒ Object
Return Annotated Table Group representation
1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-tabular-52804f52e930/lib/rdf/tabular/metadata.rb', line 1370 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 |