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.



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

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



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

def data=(value)
  @data = value
end

Instance Method Details

#+(other) ⇒ Object



122
123
124
125
# File 'lib/cucumber/core/test/location.rb', line 122

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

#firstObject



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

def first
  data.first
end

#include?(other) ⇒ Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/cucumber/core/test/location.rb', line 118

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

#inspectObject



134
135
136
# File 'lib/cucumber/core/test/location.rb', line 134

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

#maxObject



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

def max
  data.max
end

#minObject



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

def min
  data.min
end

#to_sObject



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

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

  data.to_a.join(':')
end