Module: Pione::Util::Positionable
- Included in:
- Lang::ConditionalBranch, Lang::Declaration, Lang::Expr, Lang::LiteralContext, Lang::Piece, Lang::Sequence
- Defined in:
- lib/pione/util/positionable.rb
Overview
Positionable provides the function that stores its source position information to objects.
Instance Method Summary collapse
-
#line_and_column ⇒ Object
Return the line and column.
-
#pos ⇒ Object
Return the source position.
-
#set_source_position(*args) ⇒ Object
Set source position informations of the object.
Instance Method Details
#line_and_column ⇒ Object
Return the line and column. If source position isn't established, return nil simply.
30 31 32 33 34 |
# 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 ⇒ Object
Return the source position.
24 25 26 |
# File 'lib/pione/util/positionable.rb', line 24 def pos @__source_position__ || SourcePosition.unknown end |
#set_source_position(*args) ⇒ Object
Set source position informations of the object.
15 16 17 18 19 20 21 |
# 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 |