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



185
186
187
# File 'lib/cem/cruzzles.rb', line 185

def p1
  @p1
end

#p2Object

Returns the value of attribute p2

Returns:

  • (Object)

    the current value of p2



185
186
187
# File 'lib/cem/cruzzles.rb', line 185

def p2
  @p2
end

Instance Method Details

#to_sObject



186
187
188
# File 'lib/cem/cruzzles.rb', line 186

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

#x_rangeObject



190
191
192
193
194
195
196
# File 'lib/cem/cruzzles.rb', line 190

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

#y_rangeObject



198
199
200
201
202
203
204
# File 'lib/cem/cruzzles.rb', line 198

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