Class: StackDeck::Frame::SQL

Inherits:
StackDeck::Frame show all
Defined in:
lib/stackdeck/frame.rb

Instance Attribute Summary

Attributes inherited from StackDeck::Frame

#clue, #filename, #function, #lineno

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from StackDeck::Frame

#boundary?, #language, #same_line?, #to_s

Constructor Details

#initialize(query, lineno = nil, clue = nil) ⇒ SQL

Returns a new instance of SQL.



110
111
112
113
# File 'lib/stackdeck/frame.rb', line 110

def initialize(query, lineno=nil, clue=nil)
  @query = query
  super(nil, nil, lineno, clue)
end

Class Method Details

.from_char(query, position) ⇒ Object



104
105
106
107
108
# File 'lib/stackdeck/frame.rb', line 104

def self.from_char(query, position)
  before = query[0, position.to_i]
  lineno = 1 + before.size - before.gsub(/\n/, '').size
  self.new(query, lineno)
end

Instance Method Details

#contextObject



114
115
116
# File 'lib/stackdeck/frame.rb', line 114

def context
  @context ||= Context.new(@query.split(/\n/), lineno) if @query
end

#context?Boolean

Returns:

  • (Boolean)


117
118
119
# File 'lib/stackdeck/frame.rb', line 117

def context?
  !@query.nil?
end