Class: Ldpath::FieldMapping
- Inherits:
-
Object
- Object
- Ldpath::FieldMapping
- Defined in:
- lib/ldpath/field_mapping.rb
Instance Attribute Summary collapse
-
#field_type ⇒ Object
readonly
Returns the value of attribute field_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#selector ⇒ Object
readonly
Returns the value of attribute selector.
Instance Method Summary collapse
- #evaluate(program, uri, context) ⇒ Object
-
#initialize(name:, selector:, field_type: nil, options: {}) ⇒ FieldMapping
constructor
A new instance of FieldMapping.
Constructor Details
#initialize(name:, selector:, field_type: nil, options: {}) ⇒ FieldMapping
Returns a new instance of FieldMapping.
7 8 9 10 11 12 |
# File 'lib/ldpath/field_mapping.rb', line 7 def initialize(name:, selector:, field_type: nil, options: {}) @name = name.to_s @selector = selector @field_type = field_type @options = end |
Instance Attribute Details
#field_type ⇒ Object (readonly)
Returns the value of attribute field_type.
5 6 7 |
# File 'lib/ldpath/field_mapping.rb', line 5 def field_type @field_type end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/ldpath/field_mapping.rb', line 5 def name @name end |
#selector ⇒ Object (readonly)
Returns the value of attribute selector.
5 6 7 |
# File 'lib/ldpath/field_mapping.rb', line 5 def selector @selector end |
Instance Method Details
#evaluate(program, uri, context) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ldpath/field_mapping.rb', line 14 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 |