Class: CyberarmEngine::Paint
- Inherits:
-
Object
- Object
- CyberarmEngine::Paint
- Defined in:
- lib/cyberarm_engine/background.rb
Instance Attribute Summary collapse
-
#bottom_left ⇒ Object
Returns the value of attribute bottom_left.
-
#bottom_right ⇒ Object
Returns the value of attribute bottom_right.
-
#top_left ⇒ Object
Returns the value of attribute top_left.
-
#top_right ⇒ Object
Returns the value of attribute top_right.
Instance Method Summary collapse
-
#initialize(background) ⇒ Paint
constructor
A new instance of Paint.
- #set(background) ⇒ Object
Constructor Details
#initialize(background) ⇒ Paint
Returns a new instance of Paint.
103 104 105 |
# File 'lib/cyberarm_engine/background.rb', line 103 def initialize(background) set(background) end |
Instance Attribute Details
#bottom_left ⇒ Object
Returns the value of attribute bottom_left.
101 102 103 |
# File 'lib/cyberarm_engine/background.rb', line 101 def bottom_left @bottom_left end |
#bottom_right ⇒ Object
Returns the value of attribute bottom_right.
101 102 103 |
# File 'lib/cyberarm_engine/background.rb', line 101 def bottom_right @bottom_right end |
#top_left ⇒ Object
Returns the value of attribute top_left.
101 102 103 |
# File 'lib/cyberarm_engine/background.rb', line 101 def top_left @top_left end |
#top_right ⇒ Object
Returns the value of attribute top_right.
101 102 103 |
# File 'lib/cyberarm_engine/background.rb', line 101 def top_right @top_right end |
Instance Method Details
#set(background) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/cyberarm_engine/background.rb', line 107 def set(background) @background = background if background.is_a?(Numeric) @top_left = background @top_right = background @bottom_left = background @bottom_right = background elsif background.is_a?(Gosu::Color) @top_left = background @top_right = background @bottom_left = background @bottom_right = background elsif background.is_a?(Array) if background.size == 1 set(background.first) elsif background.size == 2 @top_left = background.first @top_right = background.last @bottom_left = background.first @bottom_right = background.last elsif background.size == 4 @top_left = background[0] @top_right = background[1] @bottom_left = background[2] @bottom_right = background[3] else raise ArgumentError, "background array was empty or had wrong number of elements (expected 2 or 4 elements)" end elsif background.is_a?(Hash) @top_left = background[:top_left] @top_right = background[:top_right] @bottom_left = background[:bottom_left] @bottom_right = background[:bottom_right] elsif background.is_a?(Range) set([background.begin, background.begin, background.end, background.end]) else raise ArgumentError, "background '#{background.inspect}' of type '#{background.class}' was not able to be processed" end end |