Class: Cucumber::Core::Ast::Location
- Inherits:
-
Struct
- Object
- Struct
- Cucumber::Core::Ast::Location
- Extended by:
- Forwardable
- Defined in:
- lib/cucumber/core/ast/location.rb
Defined Under Namespace
Constant Summary collapse
- WILDCARD =
:*
Instance Attribute Summary collapse
-
#filepath ⇒ Object
Returns the value of attribute filepath.
-
#lines ⇒ Object
Returns the value of attribute lines.
Class Method Summary collapse
Instance Method Summary collapse
- #hash ⇒ Object
-
#initialize(filepath, raw_lines = WILDCARD) ⇒ Location
constructor
A new instance of Location.
- #inspect ⇒ Object
- #match?(other) ⇒ Boolean
- #on_line(new_line) ⇒ Object
- #to_s ⇒ Object
- #to_str ⇒ Object
Constructor Details
#initialize(filepath, raw_lines = WILDCARD) ⇒ Location
Returns a new instance of Location.
21 22 23 24 |
# File 'lib/cucumber/core/ast/location.rb', line 21 def initialize(filepath, raw_lines=WILDCARD) filepath || raise(ArgumentError, "file is mandatory") super(FilePath.new(filepath), Lines.new(raw_lines)) end |
Instance Attribute Details
#filepath ⇒ Object
Returns the value of attribute filepath
6 7 8 |
# File 'lib/cucumber/core/ast/location.rb', line 6 def filepath @filepath end |
#lines ⇒ Object
Returns the value of attribute lines
6 7 8 |
# File 'lib/cucumber/core/ast/location.rb', line 6 def lines @lines end |
Class Method Details
.of_caller ⇒ Object
16 17 18 19 |
# File 'lib/cucumber/core/ast/location.rb', line 16 def self.of_caller file, raw_line = *caller[1].split(':')[0..1] new(file, raw_line.to_i) end |
Instance Method Details
#hash ⇒ Object
34 35 36 |
# File 'lib/cucumber/core/ast/location.rb', line 34 def hash self.class.hash ^ to_s.hash end |
#inspect ⇒ Object
46 47 48 |
# File 'lib/cucumber/core/ast/location.rb', line 46 def inspect "<#{self.class}: #{to_s}>" end |
#match?(other) ⇒ Boolean
26 27 28 |
# File 'lib/cucumber/core/ast/location.rb', line 26 def match?(other) other.same_as?(filepath) && other.include?(lines) end |
#on_line(new_line) ⇒ Object
42 43 44 |
# File 'lib/cucumber/core/ast/location.rb', line 42 def on_line(new_line) Location.new(filepath.filename, new_line) end |
#to_s ⇒ Object
30 31 32 |
# File 'lib/cucumber/core/ast/location.rb', line 30 def to_s [filepath.to_s, lines.to_s].reject { |v| v == WILDCARD.to_s }.join(":") end |
#to_str ⇒ Object
38 39 40 |
# File 'lib/cucumber/core/ast/location.rb', line 38 def to_str to_s end |