Class: RDF::Tabular::Table

Inherits:
Metadata show all
Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-tabular-e6dd10a784d9/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

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)


1427
1428
1429
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-tabular-e6dd10a784d9/lib/rdf/tabular/metadata.rb', line 1427

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

#to_atdObject

Return Annotated Table representation



1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-tabular-e6dd10a784d9/lib/rdf/tabular/metadata.rb', line 1443

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



1432
1433
1434
1435
1436
1437
1438
1439
1440
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-tabular-e6dd10a784d9/lib/rdf/tabular/metadata.rb', line 1432

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