Class: Pho::Update::LiteralStatement

Inherits:
Statement
  • Object
show all
Defined in:
lib/pho/changeset.rb

Instance Attribute Summary collapse

Attributes inherited from Statement

#object, #predicate, #subject

Instance Method Summary collapse

Methods inherited from Statement

create_literal, create_resource, #to_rdf

Constructor Details

#initialize(subject, predicate, object, language = nil, datatype = nil) ⇒ LiteralStatement

Create a Statement referring to a literal. Can have one of lang or datatype but not both

subject:: URI of subject of triple
predicate:: URI of predicate of triple
object:: literal value
lang:: language for literal
datatype:: datatype for literal


86
87
88
89
90
91
92
93
# File 'lib/pho/changeset.rb', line 86

def initialize(subject, predicate, object, language=nil, datatype=nil)
  super(subject, predicate, object)
  if language != nil && datatype != nil
    raise "Cannot specify both language and datatype for a literal"
  end         
  @language = language
  @datatype = datatype
end

Instance Attribute Details

#datatypeObject (readonly)

Datatype for literals



77
78
79
# File 'lib/pho/changeset.rb', line 77

def datatype
  @datatype
end

#languageObject (readonly)

Language for literals



75
76
77
# File 'lib/pho/changeset.rb', line 75

def language
  @language
end

Instance Method Details

#==(other) ⇒ Object



95
96
97
98
99
100
101
102
103
104
# File 'lib/pho/changeset.rb', line 95

def ==(other)
 if other == nil
   return false
 end
 return @subject == other.subject &&
        @predicate == other.predicate &&
        @object == other.object &&
        @lang == other.language &&
        @datatype == other.datatype
end