Class: Cucumber::Core::Test::Location::Lines

Inherits:
Struct
  • Object
show all
Defined in:
lib/cucumber/core/test/location.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_data) ⇒ Lines

Returns a new instance of Lines.



94
95
96
# File 'lib/cucumber/core/test/location.rb', line 94

def initialize(raw_data)
  super Array(raw_data).to_set
end

Instance Attribute Details

#data=(value) ⇒ Object

Sets the attribute data

Parameters:

  • value (Object)

    the value to set the attribute data to.

Returns:

  • (Object)

    the newly set value



91
92
93
# File 'lib/cucumber/core/test/location.rb', line 91

def data=(value)
  @data = value
end

Instance Method Details

#+(more_lines) ⇒ Object



114
115
116
117
# File 'lib/cucumber/core/test/location.rb', line 114

def +(more_lines)
  new_data = data + more_lines.data
  self.class.new(new_data)
end

#firstObject



98
99
100
# File 'lib/cucumber/core/test/location.rb', line 98

def first
  data.first
end

#include?(other) ⇒ Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/cucumber/core/test/location.rb', line 110

def include?(other)
  other.data.subset?(data) || data.subset?(other.data)
end

#inspectObject



125
126
127
# File 'lib/cucumber/core/test/location.rb', line 125

def inspect
  "<#{self.class}: #{to_s}>"
end

#maxObject



106
107
108
# File 'lib/cucumber/core/test/location.rb', line 106

def max
  data.max
end

#minObject



102
103
104
# File 'lib/cucumber/core/test/location.rb', line 102

def min
  data.min
end

#to_sObject



119
120
121
122
123
# File 'lib/cucumber/core/test/location.rb', line 119

def to_s
  return first.to_s if data.length == 1
  return "#{data.min}..#{data.max}" if range?
  data.to_a.join(":")
end