Class: SeeingIsBelieving::Line

Inherits:
Object
  • Object
show all
Includes:
Enumerable, HasException
Defined in:
lib/seeing_is_believing/line.rb

Overview

thin wrapper over an array, used by the result

Instance Attribute Summary

Attributes included from HasException

#exception

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(array = []) ⇒ Line

Returns a new instance of Line.



25
26
27
# File 'lib/seeing_is_believing/line.rb', line 25

def initialize(array = [])
  @array = array.dup
end

Class Method Details

.[](*elements) ⇒ Object



5
6
7
# File 'lib/seeing_is_believing/line.rb', line 5

def self.[](*elements)
  new(elements)
end

Instance Method Details

#==(ary_or_line) ⇒ Object



29
30
31
32
# File 'lib/seeing_is_believing/line.rb', line 29

def ==(ary_or_line)
  return @array == ary_or_line if Array === ary_or_line
  ary_or_line == @array && exception == ary_or_line.exception
end

#inspectObject



34
35
36
37
# File 'lib/seeing_is_believing/line.rb', line 34

def inspect
  inspected_exception = has_exception? ? "#{exception.class}:#{exception.message.inspect}" : "no exception"
  "#<SIB:Line#{@array.inspect} #{inspected_exception}>"
end

#to_aObject Also known as: to_ary



20
21
22
# File 'lib/seeing_is_believing/line.rb', line 20

def to_a
  @array.dup
end