Class: Amigo::Variable
- Includes:
- Hamster::Immutable
- Defined in:
- lib/amigo/variable.rb
Instance Method Summary collapse
- #bind(statement, row) ⇒ Object
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(component, name) ⇒ Variable
constructor
A new instance of Variable.
- #join?(statement, row) ⇒ Boolean
- #select?(statement) ⇒ Boolean
- #to_sparql ⇒ Object
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: ==
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 |
#hash ⇒ Object
39 40 41 |
# File 'lib/amigo/variable.rb', line 39 def hash @component.hash ^ @name.hash end |
#join?(statement, row) ⇒ 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
14 15 16 |
# File 'lib/amigo/variable.rb', line 14 def select?(statement) true end |
#to_sparql ⇒ Object
27 28 29 |
# File 'lib/amigo/variable.rb', line 27 def to_sparql "?#{@name}" end |