class RDF::Tabular::Column

Constants

DEFAULTS
PROPERTIES
REQUIRED

Public Instance Methods

has_annotations?() click to toggle source

Does the Metadata or any descendant have any common properties @return [Boolean]

Calls superclass method RDF::Tabular::Metadata#has_annotations?
# File lib/rdf/tabular/metadata.rb, line 1602
def has_annotations?
  super || columns.any? {|c| c.has_annotations? }
end
id() click to toggle source

Identifier for this Column, as an RFC7111 fragment @return [RDF::URI]

# File lib/rdf/tabular/metadata.rb, line 1638
def id;
  url = table ? table.url : RDF::URI("")
  url.to_s + "#col=#{self.sourceNumber}";
end
name() click to toggle source

Return or create a name for the column from titles, if it exists

# File lib/rdf/tabular/metadata.rb, line 1627
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() click to toggle source

Column number set on initialization @return [Integer] 1-based colnum number

# File lib/rdf/tabular/metadata.rb, line 1587
def number
  @options.fetch(:number, 0)
end
sourceNumber() click to toggle source

Source Column number set on initialization

@note this is lazy evaluated to avoid dependencies on setting dialect vs. initializing columns @return [Integer] 1-based colnum number

# File lib/rdf/tabular/metadata.rb, line 1595
def sourceNumber
  skipColumns = table ? dialect.skipColumns.to_i : 0
  number + skipColumns
end
table() click to toggle source

Table containing this column (if any) @return [Table]

# File lib/rdf/tabular/metadata.rb, line 1583
def table; @options[:table]; end
to_atd() click to toggle source

Return Annotated Column representation

# File lib/rdf/tabular/metadata.rb, line 1644
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