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.



105
106
107
# File 'lib/cucumber/core/ast/location.rb', line 105

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



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

def data=(value)
  @data = value
end

Instance Method Details

#+(more_lines) ⇒ Object



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

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

#firstObject



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

def first
  data.first
end

#include?(other) ⇒ Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/cucumber/core/ast/location.rb', line 113

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

#inspectObject



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

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

#to_sObject



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

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