Class: DiamondLang::Helpers::Block

Inherits:
Object
  • Object
show all
Defined in:
lib/diamond-lang/helpers/block.rb

Direct Known Subclasses

CommandBlock

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, data_value = 0, nbt = nil) ⇒ Block

Returns a new instance of Block.



5
6
7
8
9
# File 'lib/diamond-lang/helpers/block.rb', line 5

def initialize(id, data_value=0, nbt=nil)
  @id = id
  @data_value = data_value
  @nbt = nbt
end

Instance Attribute Details

#data_valueObject

Returns the value of attribute data_value.



4
5
6
# File 'lib/diamond-lang/helpers/block.rb', line 4

def data_value
  @data_value
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/diamond-lang/helpers/block.rb', line 4

def id
  @id
end

#nbtObject

Returns the value of attribute nbt.



4
5
6
# File 'lib/diamond-lang/helpers/block.rb', line 4

def nbt
  @nbt
end

Instance Method Details

#to_falling_sandObject



13
14
15
# File 'lib/diamond-lang/helpers/block.rb', line 13

def to_falling_sand
  FallingSand.new self
end

#to_s(replace_method = nil) ⇒ Object



10
11
12
# File 'lib/diamond-lang/helpers/block.rb', line 10

def to_s(replace_method=nil)
  [id, data_value, replace_method, nbt.to_json].select{|e| e && e != 'null'}.join(' ')
end