Class: YPS::Position
- Inherits:
-
Object
- Object
- YPS::Position
- Defined in:
- lib/yps/value.rb
Overview
Position is a placeholder retaining position information of a parsed object.
Fields:
filename-
File name of the original YAML file.
line-
Line number in the original YAML string where a parsed object is started.
column-
Column number in the original YAML string where a parsed object is started.
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Accessor for the column number where the parsed object is started.
-
#filename ⇒ Object
readonly
Accessor for the filename of the orignal YAML file.
-
#line ⇒ Object
readonly
Accessor for the line number where the parsed object is started.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Equality operator.
-
#initialize(filename, line, column) ⇒ Position
constructor
:nodoc:.
-
#to_s ⇒ Object
Return a string representing the position information.
Constructor Details
#initialize(filename, line, column) ⇒ Position
:nodoc:
15 16 17 18 19 20 |
# File 'lib/yps/value.rb', line 15 def initialize(filename, line, column) # :nodoc: @filename = filename @line = line @column = column freeze end |
Instance Attribute Details
#column ⇒ Object (readonly)
Accessor for the column number where the parsed object is started.
32 33 34 |
# File 'lib/yps/value.rb', line 32 def column @column end |
#filename ⇒ Object (readonly)
Accessor for the filename of the orignal YAML file
24 25 26 |
# File 'lib/yps/value.rb', line 24 def filename @filename end |
#line ⇒ Object (readonly)
Accessor for the line number where the parsed object is started.
28 29 30 |
# File 'lib/yps/value.rb', line 28 def line @line end |
Instance Method Details
#==(other) ⇒ Object
Equality operator. Check whether or not self and other point the same position.
43 44 45 |
# File 'lib/yps/value.rb', line 43 def ==(other) filename == other.filename && line == other.line && column == other.column end |
#to_s ⇒ Object
Return a string representing the position information.
36 37 38 |
# File 'lib/yps/value.rb', line 36 def to_s "filename: #{filename || 'unknown'} line #{line} column #{column}" end |