Class: Tripod::Fields::Standard

Inherits:
Object
  • Object
show all
Defined in:
lib/tripod/fields/standard.rb

Overview

Defines the behaviour for defined fields in the resource.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, predicate, options = {}) ⇒ Standard

Create the new field with a name and optional additional options.

 @option options [ String, RDF::URI ] datatype The uri of the datatype for the field (will be used to create an RDF::Literal of the right type on the way in only).

Examples:

Create the new field.

Field.new(:name, 'http://foo', opts)

Parameters:

  • name (String)

    The field name.

  • predicate (String, RDF::URI)

    The field’s predicate.

  • options (Hash) (defaults to: {})

    The field options.

Options Hash (options):

  • multivalued (Boolean)

    Is this a multi-valued field? Default is false.



22
23
24
25
26
27
28
29
# File 'lib/tripod/fields/standard.rb', line 22

def initialize(name, predicate, options = {})
  @name = name
  @options = options
  @predicate = RDF::URI.new(predicate.to_s)
  @datatype = RDF::URI.new(options[:datatype].to_s) if options[:datatype]
  @is_uri = !!options[:is_uri]
  @multivalued = options[:multivalued] || false
end

Instance Attribute Details

#datatypeObject

Set readers for the instance variables.



7
8
9
# File 'lib/tripod/fields/standard.rb', line 7

def datatype
  @datatype
end

#is_uriObject Also known as: is_uri?

Set readers for the instance variables.



7
8
9
# File 'lib/tripod/fields/standard.rb', line 7

def is_uri
  @is_uri
end

#multivaluedObject Also known as: multivalued?

Set readers for the instance variables.



7
8
9
# File 'lib/tripod/fields/standard.rb', line 7

def multivalued
  @multivalued
end

#nameObject

Set readers for the instance variables.



7
8
9
# File 'lib/tripod/fields/standard.rb', line 7

def name
  @name
end

#optionsObject

Set readers for the instance variables.



7
8
9
# File 'lib/tripod/fields/standard.rb', line 7

def options
  @options
end

#predicateObject

Set readers for the instance variables.



7
8
9
# File 'lib/tripod/fields/standard.rb', line 7

def predicate
  @predicate
end