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.



100
101
102
# File 'lib/cucumber/core/test/location.rb', line 100

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



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

def data=(value)
  @data = value
end

Instance Method Details

#+(other) ⇒ Object



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

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

#firstObject



104
105
106
# File 'lib/cucumber/core/test/location.rb', line 104

def first
  data.first
end

#include?(other) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#inspectObject



132
133
134
# File 'lib/cucumber/core/test/location.rb', line 132

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

#maxObject



112
113
114
# File 'lib/cucumber/core/test/location.rb', line 112

def max
  data.max
end

#minObject



108
109
110
# File 'lib/cucumber/core/test/location.rb', line 108

def min
  data.min
end

#to_sObject



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

def to_s
  return first.to_s if data.length == 1
  return "#{data.min}..#{data.max}" if range?

  data.to_a.join(':')
end