Class: RDF::Tabular::Table

Inherits:
Metadata show all
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,
  dialect:             :object,
  notes:               :array,
  suppressOutput:      :atomic,
  tableDirection:      :atomic,
  tableSchema:         :object,
  transformations:     :array,
  url:                 :link,
}.freeze
DEFAULTS =
{
  suppressOutput:      false,
  tableDirection:      "auto".freeze,
}.freeze
REQUIRED =
[:url].freeze

Constants inherited from Metadata

Metadata::DATATYPES, Metadata::INHERITED_DEFAULTS, Metadata::INHERITED_PROPERTIES, Metadata::LOCAL_CONTEXT, Metadata::NAME_SYNTAX

Constants included from Util::Logger

Util::Logger::IOWrapper

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

#has_annotations?Boolean

Does the Metadata or any descendant have any common properties

Returns:

  • (Boolean)


1435
1436
1437
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-tabular-52804f52e930/lib/rdf/tabular/metadata.rb', line 1435

def has_annotations?
  super || tableSchema && tableSchema.has_annotations?
end

#to_atdObject

Return Annotated Table representation



1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-tabular-52804f52e930/lib/rdf/tabular/metadata.rb', line 1451

def to_atd
  object.inject({
    "@id" => (id.to_s if id),
    "@type" => "AnnotatedTable",
    "url" => self.url.to_s,
    "tableSchema" => (tableSchema.to_atd if tableSchema),
  }) 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

#to_table_groupObject

Return a new TableGroup based on this Table



1440
1441
1442
1443
1444
1445
1446
1447
1448
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-tabular-52804f52e930/lib/rdf/tabular/metadata.rb', line 1440

def to_table_group
  content = {"@type" => "TableGroup", "tables" => [self]}
  content['@context'] = object.delete(:@context) if object[:@context]
  ctx = @context
  remove_instance_variable(:@context) if instance_variables.include?(:@context)
  tg = TableGroup.new(content, **@options.merge(context: ctx, filenames: @filenames, base: base))
  @parent = tg  # Link from parent
  tg
end