Class: RubyBreaker::Position

Inherits:
Object
  • Object
show all
Defined in:
lib/rubybreaker/debug/context.rb

Overview

This class represents a position of the type acquired from either the type signature or code during runtime. It can also be used for internal error checking or debuging purpose.

Constant Summary collapse

@@file =
""
@@line =
-1
@@col =
-1

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file = "", line = -1,, col = -1,, meth = "") ⇒ Position

Returns a new instance of Position.



23
24
25
26
27
28
# File 'lib/rubybreaker/debug/context.rb', line 23

def initialize(file="",line=-1,col=-1,meth="")
  @file = file
  @line = line
  @col = col
  @method = meth
end

Instance Attribute Details

#colObject

Returns the value of attribute col.



16
17
18
# File 'lib/rubybreaker/debug/context.rb', line 16

def col
  @col
end

#fileObject

Returns the value of attribute file.



14
15
16
# File 'lib/rubybreaker/debug/context.rb', line 14

def file
  @file
end

#lineObject

Returns the value of attribute line.



15
16
17
# File 'lib/rubybreaker/debug/context.rb', line 15

def line
  @line
end

#methodObject

Returns the value of attribute method.



17
18
19
# File 'lib/rubybreaker/debug/context.rb', line 17

def method
  @method
end

Class Method Details

.convert_caller_to_pos(caller_ary, idx = 0) ⇒ Object

This class method is a utility function to convert a string in the caller() array.



49
50
51
52
# File 'lib/rubybreaker/debug/context.rb', line 49

def self.convert_caller_to_pos(caller_ary, idx=0)
  tokens = caller_ary[idx].split(":")
  return self.new(tokens[0],tokens[1],-1,tokens[2]) # no col 
end

.getObject

This class method returns a new position object for the current parsing position.



43
44
45
# File 'lib/rubybreaker/debug/context.rb', line 43

def self.get()
  return Position.new(@@file,@@line,@@col)
end

.set(file, line, col) ⇒ Object

This class method is to set the current parsing position.



35
36
37
38
39
# File 'lib/rubybreaker/debug/context.rb', line 35

def self.set(file,line,col)
  @@file = file
  @@line = line
  @@col = col
end

Instance Method Details

#to_sObject



30
31
32
# File 'lib/rubybreaker/debug/context.rb', line 30

def to_s()
  return "#{@file}:(#{@line},#{@col}):in #{@method}"
end