Class: TraceableString
- Inherits:
-
String
- Object
- String
- TraceableString
show all
- Includes:
- Traceable
- Defined in:
- lib/traceable.rb
Overview
A string that remembers the source of its value, and can output it again when serialised to YAML.
Instance Attribute Summary
Attributes included from Traceable
#byte, #column, #file, #line
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.debug ⇒ Object
104
105
106
|
# File 'lib/traceable.rb', line 104
def self.debug
@@debug ||= false
end
|
.debug=(maybe) ⇒ Object
100
101
102
|
# File 'lib/traceable.rb', line 100
def self.debug=(maybe)
@@debug = maybe
end
|
Instance Method Details
#encode_with(coder) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/traceable.rb', line 67
def encode_with(coder)
coder.tag = nil
coder.scalar = self.to_str
if debug?
coder.scalar += " =^.^= #{@file} (line #{@line}, column #{@column})"
end
end
|
#inspect ⇒ Object
91
92
93
94
95
96
97
98
|
# File 'lib/traceable.rb', line 91
def inspect
if debug?
'"%s" (%s, line: %i, col: %i, byte: %i)' %
[self.to_str, @file, @line, @column, @byte]
else
super
end
end
|