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.
725 726 727 728 729 |
# File 'lib/casty/node.rb', line 725 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.
724 725 726 |
# File 'lib/casty/node.rb', line 724 def col_num @col_num end |
#filename ⇒ Object
Returns the value of attribute filename.
724 725 726 |
# File 'lib/casty/node.rb', line 724 def filename @filename end |
#line_num ⇒ Object
Returns the value of attribute line_num.
724 725 726 |
# File 'lib/casty/node.rb', line 724 def line_num @line_num end |
Instance Method Details
#<=>(x) ⇒ Object
733 734 735 736 737 |
# File 'lib/casty/node.rb', line 733 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
730 731 732 |
# File 'lib/casty/node.rb', line 730 def to_s (@filename ? "#@filename:" : '') << "#@line_num:#@col_num" end |