Class: MethodLog::SourceFile
- Inherits:
-
Object
- Object
- MethodLog::SourceFile
- Defined in:
- lib/method_log/source_file.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#sha ⇒ Object
readonly
Returns the value of attribute sha.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #hash ⇒ Object
-
#initialize(options = {}) ⇒ SourceFile
constructor
A new instance of SourceFile.
- #snippet(range) ⇒ Object
- #source ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ SourceFile
Returns a new instance of SourceFile.
6 7 8 9 10 11 |
# File 'lib/method_log/source_file.rb', line 6 def initialize( = {}) @path = [:path] @source = [:source] @repository = [:repository] @sha = [:sha] end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/method_log/source_file.rb', line 3 def path @path end |
#sha ⇒ Object (readonly)
Returns the value of attribute sha.
4 5 6 |
# File 'lib/method_log/source_file.rb', line 4 def sha @sha end |
Instance Method Details
#==(other) ⇒ Object
17 18 19 |
# File 'lib/method_log/source_file.rb', line 17 def ==(other) (path == other.path) && (source == other.source) end |
#hash ⇒ Object
21 22 23 |
# File 'lib/method_log/source_file.rb', line 21 def hash @sha || [path, source].hash end |
#snippet(range) ⇒ Object
25 26 27 |
# File 'lib/method_log/source_file.rb', line 25 def snippet(range) lines = source.split($/)[range].join($/) end |
#source ⇒ Object
13 14 15 |
# File 'lib/method_log/source_file.rb', line 13 def source @source ||= @repository.lookup(@sha).text end |