Class: Cucumber::Core::Ast::Location::Lines

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Parameters:

  • value (Object)

    the value to set the attribute data to.

Returns:

  • (Object)

    the newly set value



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

#firstObject



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

def first
  data.first
end

#include?(other) ⇒ Boolean

Returns:

  • (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

#inspectObject



127
128
129
# File 'lib/cucumber/core/ast/location.rb', line 127

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

#to_sObject



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