Class: Tone
- Inherits:
-
Object
- Object
- Tone
- Extended by:
- RgssDb::JsonableConstructor
- Includes:
- RgssDb::Jsonable
- Defined in:
- lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb,
lib/rgss_db/model/rpg_maker_data/xp/rgss/tone.rb,
lib/rgss_db/model/rpg_maker_data/vx_ace/rgss/tone.rb
Overview
The color tone class.
Each component is handled with a floating-point value (Float).
Instance Attribute Summary collapse
-
#blue ⇒ Object
Returns the value of attribute blue.
-
#gray ⇒ Object
Returns the value of attribute gray.
-
#green ⇒ Object
Returns the value of attribute green.
-
#red ⇒ Object
Returns the value of attribute red.
Class Method Summary collapse
-
._load(serialized_string) ⇒ Tone
Creates a new instance using the given binary data.
-
.new_serialized(serialized_string) ⇒ Tone
Creates a new instance from a serialized string.
Instance Method Summary collapse
-
#_dump ⇒ String
Dumps this instance into a binary string.
-
#initialize(red = 0, green = 0, blue = 0, gray = 0) ⇒ Tone
constructor
Creates a Tone object.
Methods included from RgssDb::JsonableConstructor
Methods included from RgssDb::Jsonable
Constructor Details
#initialize(red = 0, green = 0, blue = 0, gray = 0) ⇒ Tone
Creates a Tone object. If gray is omitted, it is assumed to be 0.
The default values when no arguments are specified are (0, 0, 0, 0).
22 23 24 25 26 27 |
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb', line 22 def initialize(red = 0, green = 0, blue = 0, gray = 0) @red = red @green = green @blue = blue @gray = gray end |
Instance Attribute Details
#blue ⇒ Object
Returns the value of attribute blue.
71 72 73 |
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb', line 71 def blue @blue end |
#gray ⇒ Object
Returns the value of attribute gray.
71 72 73 |
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb', line 71 def gray @gray end |
#green ⇒ Object
Returns the value of attribute green.
71 72 73 |
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb', line 71 def green @green end |
#red ⇒ Object
Returns the value of attribute red.
71 72 73 |
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb', line 71 def red @red end |
Class Method Details
._load(serialized_string) ⇒ Tone
Creates a new instance using the given binary data
Note: needed for Marshal module support
50 51 52 |
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb', line 50 def self._load(serialized_string) Tone.new_serialized(serialized_string) end |
.new_serialized(serialized_string) ⇒ Tone
Creates a new instance from a serialized string
Note: needed for Marshal module support
63 64 65 66 67 68 69 |
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb', line 63 def self.new_serialized(serialized_string) # double, double, double, double (double-precision) red, green, blue, gray = serialized_string.unpack("dddd") # Creates the instance Tone.new(red, green, blue, gray) end |
Instance Method Details
#_dump ⇒ String
Dumps this instance into a binary string
Note: needed for Marshal module support
36 37 38 39 |
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb', line 36 def _dump(*) # double, double, double, double (double-precision) [@red, @green, @blue, @gray].pack("dddd") end |