class Ldpath::FieldMapping
Attributes
field_type[R]
name[R]
selector[R]
Public Class Methods
new(name:, selector:, field_type: nil, options: {})
click to toggle source
# File lib/ldpath/field_mapping.rb, line 5 def initialize(name:, selector:, field_type: nil, options: {}) @name = name.to_s @selector = selector @field_type = field_type @options = options end
Public Instance Methods
evaluate(program, uri, context) { |transform_value(value)| ... }
click to toggle source
# File lib/ldpath/field_mapping.rb, line 12 def evaluate(program, uri, context) case selector when Ldpath::Selector return to_enum(:evaluate, program, uri, context) unless block_given? selector.evaluate(program, uri, context).each do |value| yield transform_value(value) end when RDF::Literal Array(selector.canonicalize.object) else Array(selector) end end
Private Instance Methods
transform_value(value)
click to toggle source
# File lib/ldpath/field_mapping.rb, line 29 def transform_value(value) v = if value.is_a? RDF::Literal value.canonicalize.object else value end if field_type RDF::Literal.new(v.to_s, datatype: field_type).canonicalize.object else v end end