Class: RubyCraft::BlockType
- Inherits:
-
Object
- Object
- RubyCraft::BlockType
- Defined in:
- lib/rubycraft/block_type.rb
Overview
class methods and dsl for block
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#transparent ⇒ Object
readonly
Returns the value of attribute transparent.
Class Method Summary collapse
- .[](key) ⇒ Object
- .block(id, name, transparent = false) ⇒ Object
- .get(key) ⇒ Object
- .of(key) ⇒ Object
- .transparent_block(id, name) ⇒ Object
Instance Method Summary collapse
-
#initialize(id, name, transparent) ⇒ BlockType
constructor
A new instance of BlockType.
Constructor Details
#initialize(id, name, transparent) ⇒ BlockType
Returns a new instance of BlockType.
157 158 159 160 161 |
# File 'lib/rubycraft/block_type.rb', line 157 def initialize(id, name, transparent) @id = id @name = name.to_s @transparent = transparent end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
155 156 157 |
# File 'lib/rubycraft/block_type.rb', line 155 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
155 156 157 |
# File 'lib/rubycraft/block_type.rb', line 155 def name @name end |
#transparent ⇒ Object (readonly)
Returns the value of attribute transparent.
155 156 157 |
# File 'lib/rubycraft/block_type.rb', line 155 def transparent @transparent end |
Class Method Details
.[](key) ⇒ Object
185 186 187 188 189 |
# File 'lib/rubycraft/block_type.rb', line 185 def self.[](key) key = key.to_s return @blocks_by_name[key] if @blocks_by_name.has_key?(key) raise "no such name: #{key}" end |
.block(id, name, transparent = false) ⇒ Object
163 164 165 166 167 168 |
# File 'lib/rubycraft/block_type.rb', line 163 def self.block(id, name, transparent = false) block = new id, name, transparent @blocks[id] = block @blocks_by_name[name.to_s] = block end |
.get(key) ⇒ Object
174 175 176 177 178 179 |
# File 'lib/rubycraft/block_type.rb', line 174 def self.get(key) if @blocks.has_key?(key) return @blocks[key].clone end new(key, "unknown(#{key})", false) end |
.of(key) ⇒ Object
181 182 183 |
# File 'lib/rubycraft/block_type.rb', line 181 def self.of(key) self[key] end |
.transparent_block(id, name) ⇒ Object
170 171 172 |
# File 'lib/rubycraft/block_type.rb', line 170 def self.transparent_block(id, name) block id, name, true end |