Class: RDF::Tabular::Column
- 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, name: :atomic, suppressOutput: :atomic, titles: :natural_language, virtual: :atomic, }.freeze
- DEFAULTS =
{ suppressOutput: false, virtual: false, }.freeze
- REQUIRED =
[].freeze
Constants inherited from Metadata
Metadata::DATATYPES, Metadata::INHERITED_DEFAULTS, Metadata::INHERITED_PROPERTIES, Metadata::LOCAL_CONTEXT, Metadata::NAME_SYNTAX
Constants included from Util::Logger
Instance Attribute Summary
Attributes inherited from Metadata
#filenames, #object, #parent, #url
Instance Method Summary collapse
-
#has_annotations? ⇒ Boolean
Does the Metadata or any descendant have any common properties.
-
#id ⇒ RDF::URI
Identifier for this Column, as an RFC7111 fragment.
-
#name ⇒ Object
Return or create a name for the column from titles, if it exists.
-
#number ⇒ Integer
Column number set on initialization.
-
#sourceNumber ⇒ Integer
Source Column number set on initialization.
-
#table ⇒ Table
Table containing this column (if any).
-
#to_atd ⇒ Object
Return Annotated Column representation.
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
1604 1605 1606 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-tabular-52804f52e930/lib/rdf/tabular/metadata.rb', line 1604 def has_annotations? super || columns.any? {|c| c.has_annotations? } end |
#id ⇒ RDF::URI
Identifier for this Column, as an RFC7111 fragment
1640 1641 1642 1643 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-tabular-52804f52e930/lib/rdf/tabular/metadata.rb', line 1640 def id; url = table ? table.url : RDF::URI("") url.to_s + "#col=#{self.sourceNumber}"; end |
#name ⇒ Object
Return or create a name for the column from titles, if it exists
1629 1630 1631 1632 1633 1634 1635 1636 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-tabular-52804f52e930/lib/rdf/tabular/metadata.rb', line 1629 def name self[:name] || if titles && (ts = titles[context.default_language || 'und'] || titles[self.lang || 'und']) n = Array(ts).first n0 = RDF::URI.encode(n[0,1], /[^a-zA-Z0-9]/).encode("utf-8") n1 = RDF::URI.encode(n[1..-1], /[^\w\.]/).encode("utf-8") "#{n0}#{n1}" end || "_col.#{number}" end |
#number ⇒ Integer
Column number set on initialization
1589 1590 1591 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-tabular-52804f52e930/lib/rdf/tabular/metadata.rb', line 1589 def number @options.fetch(:number, 0) end |
#sourceNumber ⇒ Integer
this is lazy evaluated to avoid dependencies on setting dialect vs. initializing columns
Source Column number set on initialization
1597 1598 1599 1600 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-tabular-52804f52e930/lib/rdf/tabular/metadata.rb', line 1597 def sourceNumber skipColumns = table ? dialect.skipColumns.to_i : 0 number + skipColumns end |
#table ⇒ Table
Table containing this column (if any)
1585 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-tabular-52804f52e930/lib/rdf/tabular/metadata.rb', line 1585 def table; @options[:table]; end |
#to_atd ⇒ Object
Return Annotated Column representation
1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-tabular-52804f52e930/lib/rdf/tabular/metadata.rb', line 1646 def to_atd object.inject({ "@id" => id.to_s, "@type" => "Column", "table" => (table.id.to_s if table.id), "number" => self.number, "sourceNumber" => self.sourceNumber, "virtual" => self.virtual, "name" => self.name, "titles" => self.titles }) do |memo, (k, v)| memo[k.to_s] ||= v memo end.delete_if {|k,v| v.nil?} end |