Class: Vedeu::PositionValidator
- Inherits:
-
Object
- Object
- Vedeu::PositionValidator
- Extended by:
- Forwardable
- Defined in:
- lib/vedeu/geometry/position_validator.rb
Overview
Validates that the provided coordinates are within the terminal and interface’s geometry (with or without a border).
Instance Attribute Summary collapse
- #name ⇒ String readonly protected
- #x ⇒ Fixnum
- #y ⇒ Fixnum
Class Method Summary collapse
Instance Method Summary collapse
- #border ⇒ Object private
-
#initialize(name, x, y) ⇒ PositionValidator
constructor
Returns a new instance of Vedeu::PositionValidator.
-
#validate ⇒ PositionValidator
Ensures the coordinates provided are within the terminal, interface and if applicable, bordered interface area.
Constructor Details
#initialize(name, x, y) ⇒ PositionValidator
Returns a new instance of Vedeu::PositionValidator.
34 35 36 37 38 |
# File 'lib/vedeu/geometry/position_validator.rb', line 34 def initialize(name, x, y) @name = name @x = x @y = y end |
Instance Attribute Details
#name ⇒ String (readonly, protected)
57 58 59 |
# File 'lib/vedeu/geometry/position_validator.rb', line 57 def name @name end |
#x ⇒ Fixnum
17 18 19 |
# File 'lib/vedeu/geometry/position_validator.rb', line 17 def x @x end |
#y ⇒ Fixnum
21 22 23 |
# File 'lib/vedeu/geometry/position_validator.rb', line 21 def y @y end |
Class Method Details
.validate(name, x, y) ⇒ Object
24 25 26 |
# File 'lib/vedeu/geometry/position_validator.rb', line 24 def self.validate(name, x, y) new(name, x, y).validate end |
Instance Method Details
#border ⇒ Object (private)
62 63 64 |
# File 'lib/vedeu/geometry/position_validator.rb', line 62 def border @border ||= Vedeu.borders.by_name(name) end |
#validate ⇒ PositionValidator
Ensures the coordinates provided are within the terminal, interface and if applicable, bordered interface area.
44 45 46 47 48 49 50 51 |
# File 'lib/vedeu/geometry/position_validator.rb', line 44 def validate @x = bx if x < bx @x = bxn if x > bxn @y = by if y < by @y = byn if y > byn self end |