Class: XDry::Pos

Inherits:
Object
  • Object
show all
Defined in:
lib/xdry/parsing/pos.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_ref, line_no) ⇒ Pos

Returns a new instance of Pos.



54
55
56
57
58
# File 'lib/xdry/parsing/pos.rb', line 54

def initialize file_ref, line_no
  @file_ref = file_ref
  @line_no  = line_no
  @file_ref.add_pos! self
end

Instance Attribute Details

#file_refObject (readonly)

Returns the value of attribute file_ref.



51
52
53
# File 'lib/xdry/parsing/pos.rb', line 51

def file_ref
  @file_ref
end

#line_noObject (readonly)

Returns the value of attribute line_no.



51
52
53
# File 'lib/xdry/parsing/pos.rb', line 51

def line_no
  @line_no
end

#scope_afterObject

Returns the value of attribute scope_after.



52
53
54
# File 'lib/xdry/parsing/pos.rb', line 52

def scope_after
  @scope_after
end

#scope_beforeObject

Returns the value of attribute scope_before.



52
53
54
# File 'lib/xdry/parsing/pos.rb', line 52

def scope_before
  @scope_before
end

Instance Method Details

#file_pathObject



60
61
62
# File 'lib/xdry/parsing/pos.rb', line 60

def file_path
  @file_ref.path
end

#fixup!(after_line_no, offset) ⇒ Object



64
65
66
67
68
# File 'lib/xdry/parsing/pos.rb', line 64

def fixup! after_line_no, offset
  if @line_no > after_line_no
    @line_no += offset
  end
end

#to_sObject



70
71
72
# File 'lib/xdry/parsing/pos.rb', line 70

def to_s
  "#{File.basename(@file_ref.path)}:#{@line_no}"
end