Class: Stupidedi::Reader::Position
- Inherits:
-
Object
- Object
- Stupidedi::Reader::Position
- Includes:
- Inspect
- Defined in:
- lib/stupidedi/reader/position.rb
Instance Attribute Summary (collapse)
- - (Integer) column readonly
- - (Integer) line readonly
- - (Integer) offset readonly
- - (String, Pathname) path readonly
Class Method Summary (collapse)
Instance Method Summary (collapse)
- - copy(changes = {})
-
- (Position) initialize(offset, line, column, path)
constructor
A new instance of Position.
- - (String) inspect
- - pretty_print(q)
Constructor Details
- (Position) initialize(offset, line, column, path)
A new instance of Position
19 20 21 22 |
# File 'lib/stupidedi/reader/position.rb', line 19 def initialize(offset, line, column, path) @offset, @line, @column, @path = offset, line, column, path end |
Instance Attribute Details
- (Integer) column (readonly)
14 15 16 |
# File 'lib/stupidedi/reader/position.rb', line 14 def column @column end |
- (Integer) line (readonly)
11 12 13 |
# File 'lib/stupidedi/reader/position.rb', line 11 def line @line end |
- (Integer) offset (readonly)
8 9 10 |
# File 'lib/stupidedi/reader/position.rb', line 8 def offset @offset end |
- (String, Pathname) path (readonly)
17 18 19 |
# File 'lib/stupidedi/reader/position.rb', line 17 def path @path end |
Class Method Details
+ caller(offset = 1)
62 63 64 65 |
# File 'lib/stupidedi/reader/position.rb', line 62 def caller(offset = 1) path, line, method = Stupidedi.caller(offset + 1) new(nil, line, nil, path) end |
Instance Method Details
- copy(changes = {})
24 25 26 27 28 29 30 |
# File 'lib/stupidedi/reader/position.rb', line 24 def copy(changes = {}) Position.new \ changes.fetch(:offset, @offset), changes.fetch(:line, @line), changes.fetch(:column, @column), changes.fetch(:path, @path) end |
- (String) inspect
33 34 35 36 37 38 39 |
# File 'lib/stupidedi/reader/position.rb', line 33 def inspect if @path.present? "file #{@path}, line #{@line}, column #{@column}" else "line #{@line}, column #{@column}" end end |
- pretty_print(q)
This method returns an undefined value.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/stupidedi/reader/position.rb', line 42 def pretty_print(q) q.text "Position" q.group(2, "(", ")") do q.breakable "" q.text "line #{@line}," q.breakable q.text "column #{@column}," q.breakable q.text "offset #{@offset}" unless @path.nil? q.text "," q.breakable q.text "path #{@path}" end end end |