Class: Cucumber::Core::Ast::Location::Lines
- Inherits:
-
Struct
- Object
- Struct
- Cucumber::Core::Ast::Location::Lines
- Defined in:
- lib/cucumber/core/ast/location.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
writeonly
Sets the attribute data.
Instance Method Summary collapse
- #+(more_lines) ⇒ Object
- #first ⇒ Object
- #include?(other) ⇒ Boolean
-
#initialize(raw_data) ⇒ Lines
constructor
A new instance of Lines.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(raw_data) ⇒ Lines
Returns a new instance of Lines.
104 105 106 |
# File 'lib/cucumber/core/ast/location.rb', line 104 def initialize(raw_data) super Array(raw_data).to_set end |
Instance Attribute Details
#data=(value) ⇒ Object
Sets the attribute data
101 102 103 |
# File 'lib/cucumber/core/ast/location.rb', line 101 def data=(value) @data = value end |
Instance Method Details
#+(more_lines) ⇒ Object
116 117 118 119 |
# File 'lib/cucumber/core/ast/location.rb', line 116 def +(more_lines) new_data = data + more_lines.data self.class.new(new_data) end |
#first ⇒ Object
108 109 110 |
# File 'lib/cucumber/core/ast/location.rb', line 108 def first data.first end |
#include?(other) ⇒ Boolean
112 113 114 |
# File 'lib/cucumber/core/ast/location.rb', line 112 def include?(other) other.data.subset?(data) || data.subset?(other.data) end |
#inspect ⇒ Object
127 128 129 |
# File 'lib/cucumber/core/ast/location.rb', line 127 def inspect "<#{self.class}: #{to_s}>" end |
#to_s ⇒ Object
121 122 123 124 125 |
# File 'lib/cucumber/core/ast/location.rb', line 121 def to_s return first.to_s if data.length == 1 return "#{data.min}..#{data.max}" if range? data.to_a.join(":") end |