Class: RDF::Tabular::TableGroup
- Defined in:
- lib/rdf/tabular/metadata.rb
Constant Summary collapse
- PROPERTIES =
{ :@id => :link, :@type => :atomic, notes: :array, resources: :array, tableSchema: :object, tableDirection: :atomic, dialect: :object, transformations: :array, }.freeze
- REQUIRED =
[].freeze
Constants inherited from Metadata
Metadata::DATATYPES, 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
-
#each_resource {|Table| ... } ⇒ Object
Iterate over all resources.
-
#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.
-
#method_missing(method, *args) ⇒ Object
Logic for accessing elements as accessors.
-
#to_atd ⇒ Object
Return Annotated Table Group representation.
Methods inherited from Metadata
#==, #[], #[]=, #base, #common_properties, #context, #dialect, #dialect=, #each, #each_row, #errors, for_input, #initialize, #inspect, #merge, #merge!, new, #normalize!, #normalize_datatype, #normalize_jsonld, open, #to_json, #type, #valid?, #valid_inherited_property?, #valid_natural_language_property?, #validate!
Methods included from Utils
Constructor Details
This class inherits a constructor from RDF::Tabular::Metadata
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
Logic for accessing elements as accessors
1300 1301 1302 1303 1304 1305 1306 |
# File 'lib/rdf/tabular/metadata.rb', line 1300 def method_missing(method, *args) if INHERITED_PROPERTIES.has_key?(method.to_sym) inherited_property_value(method.to_sym) else PROPERTIES.has_key?(method.to_sym) ? object[method.to_sym] : super end end |
Instance Method Details
#each_resource {|Table| ... } ⇒ Object
Iterate over all resources
1311 1312 1313 1314 1315 |
# File 'lib/rdf/tabular/metadata.rb', line 1311 def each_resource resources.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
1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 |
# File 'lib/rdf/tabular/metadata.rb', line 1322 def for_table(url) # If there are no resources, assume there's one for this table #self.resources ||= [Table.new(url: url)] if table = Array(resources).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
1295 1296 1297 |
# File 'lib/rdf/tabular/metadata.rb', line 1295 def has_annotations? super || resources.any? {|t| t.has_annotations? } end |
#to_atd ⇒ Object
Return Annotated Table Group representation
1334 1335 1336 1337 1338 1339 1340 |
# File 'lib/rdf/tabular/metadata.rb', line 1334 def to_atd { "@id" => id, "@type" => "AnnotatedTableGroup", "resources" => resources.map(&:to_atd) } end |