Module: Dbd::Fact::Factory

Defined in:
lib/dbd/fact/factory.rb

Class Method Summary collapse

Class Method Details

.attribute_formatsObject

Formats for checking CSV fields the predicate, object_type and object are tested in the initializer



40
41
42
43
44
45
46
47
# File 'lib/dbd/fact/factory.rb', line 40

def attribute_formats
  {
    id: [true, Fact::ID.valid_regexp],
    time_stamp: [true, TimeStamp.valid_regexp],
    context_subject: [false, Fact::Subject.valid_regexp],
    subject: [true, Fact::Subject.valid_regexp]
  }
end

.from_string_values(string_values, options = {}) ⇒ Fact, Context

Constructs a Fact or ContextFact from a string values array (e.g. pulled from a CSV row).

Parameters:

  • string_values (Array)

    Required : the array with values, organized as in attributes

Returns:



31
32
33
34
35
# File 'lib/dbd/fact/factory.rb', line 31

def from_string_values(string_values, options={})
  string_hash = string_hash_from_values(string_values)
  validate_string_hash(string_hash) if options[:validate]
  fact_from_values_hash(values_hash(string_hash))
end

.new_idString

Returns A new id string.

Returns:

  • (String)

    A new id string.



21
22
23
# File 'lib/dbd/fact/factory.rb', line 21

def new_id
  top_class::ID.new_id
end

.new_subjectString

Returns A new subject string.

Returns:

  • (String)

    A new subject string.



15
16
17
# File 'lib/dbd/fact/factory.rb', line 15

def new_subject
  top_class::Subject.new_subject
end

.top_classClass

Returns the top class for which instances are created here.

Returns:

  • (Class)

    the top class for which instances are created here.



9
10
11
# File 'lib/dbd/fact/factory.rb', line 9

def top_class
  Fact
end