module Pione::Util::Positionable
Positionable
provides the function that stores its source position information to objects.
Public Instance Methods
line_and_column()
click to toggle source
Return the line and column. If source position isn’t established, return nil simply.
# File lib/pione/util/positionable.rb, line 30 def line_and_column if @__source_position__ return @__source_position__.line, @__source_position__.column end end
pos()
click to toggle source
Return the source position.
# File lib/pione/util/positionable.rb, line 24 def pos @__source_position__ || SourcePosition.unknown end
set_source_position(*args)
click to toggle source
Set source position informations of the object.
@example Specify package name, filename, line number, and column number
obj = Object.new.tap {|x| x.extend Positionable} obj.set_source_position("HelloWorld", "HelloWorld.pione", 1, 1)
@example SourcePosition
object
obj = Object.new.tap {|x| x.extend Positionable} obj.set_source_position(other.pos)
# File lib/pione/util/positionable.rb, line 15 def set_source_position(*args) if args.size == 1 and args[0].is_a?(SourcePosition) @__source_position__ = args[0] elsif args.size > 0 @__source_position__ = SourcePosition.new(*args) end end