Class: Seg2D

Inherits:
Struct
  • Object
show all
Defined in:
lib/cem/cruzzles.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#p1Object

Returns the value of attribute p1

Returns:

  • (Object)

    the current value of p1



213
214
215
# File 'lib/cem/cruzzles.rb', line 213

def p1
  @p1
end

#p2Object

Returns the value of attribute p2

Returns:

  • (Object)

    the current value of p2



213
214
215
# File 'lib/cem/cruzzles.rb', line 213

def p2
  @p2
end

Instance Method Details

#to_sObject



214
215
216
# File 'lib/cem/cruzzles.rb', line 214

def to_s
  "#{p1},#{p2}"
end

#x_rangeObject



218
219
220
221
222
223
224
# File 'lib/cem/cruzzles.rb', line 218

def x_range
  if p1.x < p2.x 
    return p1.x..p2.x
  else
    return p2.x..p1.x
  end
end

#y_rangeObject



226
227
228
229
230
231
232
# File 'lib/cem/cruzzles.rb', line 226

def y_range
  if p1.y < p2.y 
    return p1.y..p2.y
  else
    return p2.y..p1.y
  end
end