Class: DiamondLang::Helpers::CommandBlock
- Defined in:
- lib/diamond-lang/helpers/command_block.rb
Constant Summary collapse
- Types =
{ chain: 'chain_command_block', impulse: 'command_block', repeating: 'repeating_command_block' }.freeze
Instance Attribute Summary
Attributes inherited from Block
Instance Method Summary collapse
- #conditional=(val) ⇒ Object
- #conditional?(data_value = @data_value) ⇒ Boolean
- #direction ⇒ Object
- #direction=(val) ⇒ Object
-
#initialize(command, type = :chain, data_value = 0, auto = true, conditional = false) ⇒ CommandBlock
constructor
A new instance of CommandBlock.
- #type ⇒ Object
- #type=(type) ⇒ Object
Methods inherited from Block
Constructor Details
#initialize(command, type = :chain, data_value = 0, auto = true, conditional = false) ⇒ CommandBlock
Returns a new instance of CommandBlock.
15 16 17 18 19 20 21 |
# File 'lib/diamond-lang/helpers/command_block.rb', line 15 def initialize(command,type=:chain,data_value=0,auto=true,conditional=false) super Types[type], data_value, { Command: command.to_s, auto: auto } conditional = conditional end |
Instance Method Details
#conditional=(val) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/diamond-lang/helpers/command_block.rb', line 28 def conditional=(val) if conditional? && !val @data_value -= 8 elsif !@conditional && val @data_value += 8 end end |
#conditional?(data_value = @data_value) ⇒ Boolean
35 36 37 |
# File 'lib/diamond-lang/helpers/command_block.rb', line 35 def conditional?(data_value=@data_value) data_value >= 8 end |
#direction ⇒ Object
9 10 11 |
# File 'lib/diamond-lang/helpers/command_block.rb', line 9 def direction conditional? ? @data_value - 8 : @data_value end |
#direction=(val) ⇒ Object
12 13 14 |
# File 'lib/diamond-lang/helpers/command_block.rb', line 12 def direction=(val) @data_value = val + (conditional? ? 8 : 0) end |