Class: Hokusai::Rect

Inherits:
Object
  • Object
show all
Defined in:
ui/src/hokusai/types.rb

Overview

Rect = Struct.new(:x, :y, :width, :height) do

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y, width, height) ⇒ Rect

Returns a new instance of Rect.



8
9
10
11
12
13
# File 'ui/src/hokusai/types.rb', line 8

def initialize(x, y, width, height)
  @x = x
  @y = y
  @width = width
  @height = height
end

Instance Attribute Details

#heightObject

Returns the value of attribute height.



6
7
8
# File 'ui/src/hokusai/types.rb', line 6

def height
  @height
end

#widthObject

Returns the value of attribute width.



6
7
8
# File 'ui/src/hokusai/types.rb', line 6

def width
  @width
end

#xObject

Returns the value of attribute x.



6
7
8
# File 'ui/src/hokusai/types.rb', line 6

def x
  @x
end

#yObject

Returns the value of attribute y.



6
7
8
# File 'ui/src/hokusai/types.rb', line 6

def y
  @y
end

Class Method Details

.from_hoku_rect(rect) ⇒ Object



42
43
44
45
46
47
# File 'ui/src/hokusai/types.rb', line 42

def self.from_hoku_rect(rect)
  self.x = rect[:x]
  self.y = rect[:y]
  self.width = rect[:w]
  self.height = rect[:h]
end

Instance Method Details

#includes_x?(x) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'ui/src/hokusai/types.rb', line 22

def includes_x?(x)
  LibHokusai.hoku_rect_includes_x(to_hoku_rect, x)
end

#includes_y?(y) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'ui/src/hokusai/types.rb', line 18

def includes_y?(y)
  LibHokusai.hoku_rect_includes_y(to_hoku_rect, y)
end

#move_x_left(times = 1) ⇒ Object



26
27
28
# File 'ui/src/hokusai/types.rb', line 26

def move_x_left(times = 1)
  LibHokusai.hoku_rect_x_left(to_hoku_rect, times)
end

#move_x_right(times = 1) ⇒ Object



30
31
32
# File 'ui/src/hokusai/types.rb', line 30

def move_x_right(times = 1)
  LibHokusai.hoku_rect_x_right(to_hoku_rect, times)
end

#move_y_down(times = 1) ⇒ Object



38
39
40
# File 'ui/src/hokusai/types.rb', line 38

def move_y_down(times = 1)
  LibHokusai.hoku_rect_y_down(to_hoku_rect, times)
end

#move_y_up(times = 1) ⇒ Object



34
35
36
# File 'ui/src/hokusai/types.rb', line 34

def move_y_up(times = 1)
  LibHokusai.hoku_rect_y_up(to_hoku_rect, times)
end

#to_hoku_rectObject



14
15
16
# File 'ui/src/hokusai/types.rb', line 14

def to_hoku_rect
  @hoku_rect ||= LibHokusai::HmlRect.create(x, y, width, height)
end