Class: Rect

Inherits:
Object
  • Object
show all
Extended by:
RgssDb::JsonableConstructor
Includes:
RgssDb::Jsonable
Defined in:
lib/rgss_db/model/rpg_maker_data/vx/rgss/rect.rb,
lib/rgss_db/model/rpg_maker_data/xp/rgss/rect.rb,
lib/rgss_db/model/rpg_maker_data/vx_ace/rgss/rect.rb

Overview

The rectangle class.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RgssDb::JsonableConstructor

json_create, json_new

Methods included from RgssDb::Jsonable

#as_json, #to_json

Constructor Details

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

Creates a new Rect object.

The default values when no arguments are specified are (0, 0, 0, 0).

Parameters:

  • x (Integer) (defaults to: 0)
  • y (Integer) (defaults to: 0)
  • width (Integer) (defaults to: 0)
  • height (Integer) (defaults to: 0)


20
21
22
23
24
25
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/rect.rb', line 20

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

Instance Attribute Details

#heightObject

Returns the value of attribute height.



69
70
71
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/rect.rb', line 69

def height
  @height
end

#widthObject

Returns the value of attribute width.



69
70
71
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/rect.rb', line 69

def width
  @width
end

#xObject

Returns the value of attribute x.



69
70
71
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/rect.rb', line 69

def x
  @x
end

#yObject

Returns the value of attribute y.



69
70
71
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/rect.rb', line 69

def y
  @y
end

Class Method Details

._load(serialized_string) ⇒ Rect

Creates a new instance using the given binary data

Note: needed for Marshal module support

Parameters:

  • serialized_string (String)

Returns:



48
49
50
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/rect.rb', line 48

def self._load(serialized_string)
  Rect.new_serialized(serialized_string)
end

.new_serialized(serialized_string) ⇒ Rect

Creates a new instance from a serialized string

Note: needed for Marshal module support

Parameters:

  • serialized_string (String)

Returns:



61
62
63
64
65
66
67
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/rect.rb', line 61

def self.new_serialized(serialized_string)
  # int32_t, int32_t, int32_t, int32_t
  x, y, width, height = serialized_string.unpack("llll")

  # Creates the instance
  Rect.new(x, y, width, height)
end

Instance Method Details

#_dumpString

Dumps this instance into a binary string

Note: needed for Marshal module support

Returns:

  • (String)


34
35
36
37
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/rect.rb', line 34

def _dump(*)
  # int32_t, int32_t, int32_t, int32_t
  [@x, @y, @width, @height].pack("llll")
end