Class: RDF::Tabular::TableGroup

Inherits:
Metadata show all
Defined in:
vendor/bundler/ruby/2.4.0/bundler/gems/rdf-tabular-6243d85fc308/lib/rdf/tabular/metadata.rb

Constant Summary

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

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

Yields:



1339
1340
1341
1342
1343
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-tabular-6243d85fc308/lib/rdf/tabular/metadata.rb', line 1339

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

Parameters:

  • url (String)

    of the table

Returns:



1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-tabular-6243d85fc308/lib/rdf/tabular/metadata.rb', line 1350

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

Returns:

  • (Boolean)


1332
1333
1334
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-tabular-6243d85fc308/lib/rdf/tabular/metadata.rb', line 1332

def has_annotations?
  super || tables.any? {|t| t.has_annotations? }
end

#to_atdObject

Return Annotated Table Group representation



1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-tabular-6243d85fc308/lib/rdf/tabular/metadata.rb', line 1362

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