Class: RDF::Tabular::Table

Inherits:
Metadata show all
Defined in:
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=, #describes_file?, #dialect, #dialect=, #each, #each_row, for_input, #initialize, #inspect, new, #normalize!, #normalize_jsonld, open, 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

#has_annotations?Boolean

Does the Metadata or any descendant have any common properties

Returns:

  • (Boolean)


1433
1434
1435
# File 'lib/rdf/tabular/metadata.rb', line 1433

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

#to_atdObject

Return Annotated Table representation



1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
# File 'lib/rdf/tabular/metadata.rb', line 1449

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



1438
1439
1440
1441
1442
1443
1444
1445
1446
# File 'lib/rdf/tabular/metadata.rb', line 1438

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