Class: CFG::Location

Inherits:
Object
  • Object
show all
Defined in:
lib/CFG/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line = 1, column = 1) ⇒ Location

Returns a new instance of Location.



149
150
151
152
# File 'lib/CFG/config.rb', line 149

def initialize(line = 1, column = 1)
  @line = line
  @column = column
end

Instance Attribute Details

#columnObject

Returns the value of attribute column.



143
144
145
# File 'lib/CFG/config.rb', line 143

def column
  @column
end

#lineObject

Returns the value of attribute line.



142
143
144
# File 'lib/CFG/config.rb', line 142

def line
  @line
end

Class Method Details

.from(other) ⇒ Object



145
146
147
# File 'lib/CFG/config.rb', line 145

def self.from(other)
  Location.new other.line, other.column
end

Instance Method Details

#==(other) ⇒ Object



168
169
170
# File 'lib/CFG/config.rb', line 168

def ==(other)
  @line == other.line && @column == other.column
end

#next_lineObject



154
155
156
157
# File 'lib/CFG/config.rb', line 154

def next_line
  self.line += 1
  self.column = 1
end

#to_sObject



164
165
166
# File 'lib/CFG/config.rb', line 164

def to_s
  "(#{@line}, #{@column})"
end

#update(other) ⇒ Object



159
160
161
162
# File 'lib/CFG/config.rb', line 159

def update(other)
  @line = other.line
  @column = other.column
end