Class: Amigo::Variable

Inherits:
Object show all
Includes:
Hamster::Immutable
Defined in:
lib/amigo/variable.rb

Instance Method Summary collapse

Constructor Details

#initialize(component, name) ⇒ Variable

Returns a new instance of Variable.



9
10
11
12
# File 'lib/amigo/variable.rb', line 9

def initialize(component, name)
  @component = component
  @name = name
end

Instance Method Details

#bind(statement, row) ⇒ Object



18
19
20
# File 'lib/amigo/variable.rb', line 18

def bind(statement, row)
  row.put(@name, statement.send(@component))
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


31
32
33
34
35
36
# File 'lib/amigo/variable.rb', line 31

def eql?(other)
  return true if other.equal?(self)
  other.class.equal?(self.class) &&
    @component.eql?(other.instance_variable_get(:@component)) &&
    @name.eql?(other.instance_variable_get(:@name))
end

#hashObject



39
40
41
# File 'lib/amigo/variable.rb', line 39

def hash
  @component.hash ^ @name.hash
end

#join?(statement, row) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/amigo/variable.rb', line 22

def join?(statement, row)
  return true unless row.has_key?(@name)
  statement.send(@component) == row[@name]
end

#select?(statement) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/amigo/variable.rb', line 14

def select?(statement)
  true
end

#to_sparqlObject



27
28
29
# File 'lib/amigo/variable.rb', line 27

def to_sparql
  "?#{@name}"
end