Class: Toybot::Tabletop
- Inherits:
-
Object
- Object
- Toybot::Tabletop
- Defined in:
- lib/toybot/tabletop.rb
Constant Summary collapse
- DEFAULT_TABLETOP_WIDTH =
Default values for tabletop x & y +1.0/0.0 => Infinity
+1.0/0.0
- DEFAULT_TABLETOP_HEIGHT =
+1.0/0.0
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(width: DEFAULT_TABLETOP_WIDTH, height: DEFAULT_TABLETOP_HEIGHT) ⇒ Tabletop
constructor
A Tabletop has a width and height (Infinity by default).
- #size ⇒ Object
Constructor Details
#initialize(width: DEFAULT_TABLETOP_WIDTH, height: DEFAULT_TABLETOP_HEIGHT) ⇒ Tabletop
A Tabletop has a width and height (Infinity by default). A Tabletop has a minimum size of 1 by 1.
11 12 13 14 |
# File 'lib/toybot/tabletop.rb', line 11 def initialize width: DEFAULT_TABLETOP_WIDTH, height: DEFAULT_TABLETOP_HEIGHT @width = width > 0 ? width : 1 @height = height > 0 ? height : 1 end |
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
2 3 4 |
# File 'lib/toybot/tabletop.rb', line 2 def height @height end |
#width ⇒ Object
Returns the value of attribute width.
2 3 4 |
# File 'lib/toybot/tabletop.rb', line 2 def width @width end |
Instance Method Details
#size ⇒ Object
16 17 18 |
# File 'lib/toybot/tabletop.rb', line 16 def size {width: self.width, height: self.height} end |