Class: Fixturex::FixtureLocation
- Inherits:
-
Object
- Object
- Fixturex::FixtureLocation
- Defined in:
- lib/fixturex/fixture_location.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path, name, line = nil) ⇒ FixtureLocation
constructor
A new instance of FixtureLocation.
- #line ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(path, name, line = nil) ⇒ FixtureLocation
Returns a new instance of FixtureLocation.
5 6 7 8 9 |
# File 'lib/fixturex/fixture_location.rb', line 5 def initialize(path, name, line = nil) @path = path @name = name @line = line end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/fixturex/fixture_location.rb', line 3 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/fixturex/fixture_location.rb', line 3 def path @path end |
Instance Method Details
#line ⇒ Object
11 12 13 14 15 |
# File 'lib/fixturex/fixture_location.rb', line 11 def line @line ||= File.readlines(path).index do |line| line.match?(/^#{Regexp.escape(name)}:/) end + 1 end |
#to_h ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/fixturex/fixture_location.rb', line 17 def to_h { name: name, path: path.to_s, line: line } end |