Class: PMLCode::Source
- Inherits:
-
Object
- Object
- PMLCode::Source
- Defined in:
- lib/pmlcode/source.rb
Constant Summary collapse
- PATTERN =
/^(?<path>.+?)(:(?<line>\d+):?)?$/
Instance Attribute Summary collapse
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path, line) ⇒ Source
constructor
A new instance of Source.
- #missing? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(path, line) ⇒ Source
Returns a new instance of Source.
12 13 14 15 |
# File 'lib/pmlcode/source.rb', line 12 def initialize(path, line) @path = File.(path) @line = line end |
Instance Attribute Details
#line ⇒ Object (readonly)
Returns the value of attribute line.
11 12 13 |
# File 'lib/pmlcode/source.rb', line 11 def line @line end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/pmlcode/source.rb', line 11 def path @path end |
Class Method Details
.parse(text) ⇒ Object
5 6 7 8 9 |
# File 'lib/pmlcode/source.rb', line 5 def self.parse(text) if (match = text.match(PATTERN)) new(match[:path], match[:line] ? Integer(match[:line]) : nil) end end |
Instance Method Details
#missing? ⇒ Boolean
17 18 19 |
# File 'lib/pmlcode/source.rb', line 17 def missing? !File.exists?(@path) end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/pmlcode/source.rb', line 21 def to_s [@path, @line].join(":") end |