Class: SyntaxTree::Database::TypeQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/database.rb

Overview

Query for a specific type of node.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ TypeQuery

Returns a new instance of TypeQuery.



88
89
90
# File 'lib/syntax_tree/database.rb', line 88

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



86
87
88
# File 'lib/syntax_tree/database.rb', line 86

def type
  @type
end

Instance Method Details

#each(database, &block) ⇒ Object



92
93
94
95
# File 'lib/syntax_tree/database.rb', line 92

def each(database, &block)
  sql = "SELECT * FROM nodes WHERE type = ?"
  database.execute(sql, type).each(&block)
end