Class: C::Node::Pos
Overview
A position in a source file. All Nodes may have one in their #pos attribute.
Instance Attribute Summary collapse
-
#col_num ⇒ Object
Returns the value of attribute col_num.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#line_num ⇒ Object
Returns the value of attribute line_num.
Instance Method Summary collapse
- #<=>(x) ⇒ Object
-
#initialize(filename, line_num, col_num) ⇒ Pos
constructor
A new instance of Pos.
- #to_s ⇒ Object
Constructor Details
#initialize(filename, line_num, col_num) ⇒ Pos
Returns a new instance of Pos.
724 725 726 727 728 |
# File 'lib/cast/node.rb', line 724 def initialize(filename, line_num, col_num) @filename = filename @line_num = line_num @col_num = col_num end |
Instance Attribute Details
#col_num ⇒ Object
Returns the value of attribute col_num.
723 724 725 |
# File 'lib/cast/node.rb', line 723 def col_num @col_num end |
#filename ⇒ Object
Returns the value of attribute filename.
723 724 725 |
# File 'lib/cast/node.rb', line 723 def filename @filename end |
#line_num ⇒ Object
Returns the value of attribute line_num.
723 724 725 |
# File 'lib/cast/node.rb', line 723 def line_num @line_num end |
Instance Method Details
#<=>(x) ⇒ Object
732 733 734 735 736 |
# File 'lib/cast/node.rb', line 732 def <=>(x) return nil if self.filename != x.filename return (self.line_num <=> x.line_num).nonzero? || self.col_num <=> x.col_num end |
#to_s ⇒ Object
729 730 731 |
# File 'lib/cast/node.rb', line 729 def to_s (@filename ? "#@filename:" : '') << "#@line_num:#@col_num" end |