Class: StackDeck::Frame

Inherits:
Object
  • Object
show all
Defined in:
lib/stackdeck/frame.rb,
lib/stackdeck/postgres.rb

Direct Known Subclasses

JavaScript, Postgres::Function, Ruby, SQL

Defined Under Namespace

Modules: Postgres Classes: JavaScript, Ruby, SQL

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(function, filename, lineno, clue = nil) ⇒ Frame

Returns a new instance of Frame.



28
29
30
31
32
33
# File 'lib/stackdeck/frame.rb', line 28

def initialize(function, filename, lineno, clue=nil)
  @function = function
  @filename = filename unless filename && filename.empty?
  @lineno = lineno
  @clue = clue unless clue && clue.empty?
end

Instance Attribute Details

#clueObject

Returns the value of attribute clue.



27
28
29
# File 'lib/stackdeck/frame.rb', line 27

def clue
  @clue
end

#filenameObject

Returns the value of attribute filename.



27
28
29
# File 'lib/stackdeck/frame.rb', line 27

def filename
  @filename
end

#functionObject

Returns the value of attribute function.



27
28
29
# File 'lib/stackdeck/frame.rb', line 27

def function
  @function
end

#linenoObject

Returns the value of attribute lineno.



27
28
29
# File 'lib/stackdeck/frame.rb', line 27

def lineno
  @lineno
end

Instance Method Details

#boundary?Boolean

Returns:

  • (Boolean)


44
# File 'lib/stackdeck/frame.rb', line 44

def boundary?; false; end

#contextObject



34
35
36
# File 'lib/stackdeck/frame.rb', line 34

def context
  @context ||= Context::File.new(filename, lineno) if filename
end

#context?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/stackdeck/frame.rb', line 37

def context?
  !filename.nil?
end

#languageObject



43
# File 'lib/stackdeck/frame.rb', line 43

def language; self.class.name.split('::').last; end

#same_line?(other) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/stackdeck/frame.rb', line 40

def same_line?(other)
  other && self.filename == other.filename && self.lineno == other.lineno
end

#to_sObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/stackdeck/frame.rb', line 46

def to_s
  if filename
    if function && function != ''
      "#{filename}:#{lineno}:in `#{function}' [#{language}]"
    else
      "#{filename}:#{lineno} [#{language}]"
    end
  else
    if function && function != ''
      "(#{language}):#{lineno}:in `#{function}'"
    else
      "(#{language}):#{lineno}"
    end
  end
end