File: shape.rb

package info (click to toggle)
ruby-oj 3.16.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,192 kB
  • sloc: ansic: 19,659; ruby: 11,750; sh: 70; makefile: 17
file content (34 lines) | stat: -rw-r--r-- 580 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module Sample
  class Shape
    include HasProps

    attr_accessor :bounds
    attr_accessor :color
    attr_accessor :border, :border_color

    def initialize(left, top, wide, high, color=nil)
      @bounds = [[left, top], [left + wide, top + high]]
      @color = color
      @border = 1
      @border_color = :black
    end
    
    def left
      @bounds[0][0]
    end
    
    def top
      @bounds[0][1]
    end
    
    def width
      @bounds[1][0] - @bounds[0][0]
    end
    
    def height
      @bounds[1][1] - @bounds[0][1]
    end
    
  end # Shape
end # Sample