Class: DiamondLang::Helpers::Command
- Defined in:
- lib/diamond-lang/helpers/command.rb
Instance Attribute Summary collapse
-
#chain ⇒ Object
readonly
Returns the value of attribute chain.
-
#command ⇒ Object
Returns the value of attribute command.
Instance Method Summary collapse
-
#initialize(name, *args, &block) ⇒ Command
constructor
A new instance of Command.
- #inspect ⇒ Object
- #to_block(type = :chain) ⇒ Object
- #to_minecart ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, *args, &block) ⇒ Command
Returns a new instance of Command.
13 14 15 16 17 18 19 20 21 |
# File 'lib/diamond-lang/helpers/command.rb', line 13 def initialize(name, *args, &block) @command = name.freeze @arguments = args.flatten if block chain = CommandChain.new self block.call(chain) @chain = chain.commands.freeze end end |
Instance Attribute Details
#chain ⇒ Object (readonly)
Returns the value of attribute chain.
12 13 14 |
# File 'lib/diamond-lang/helpers/command.rb', line 12 def chain @chain end |
#command ⇒ Object
Returns the value of attribute command.
11 12 13 |
# File 'lib/diamond-lang/helpers/command.rb', line 11 def command @command end |
Instance Method Details
#inspect ⇒ Object
25 26 27 |
# File 'lib/diamond-lang/helpers/command.rb', line 25 def inspect [@command, *@arguments].join(" ") + ", success: " + @chain.inspect end |
#to_block(type = :chain) ⇒ Object
31 32 33 |
# File 'lib/diamond-lang/helpers/command.rb', line 31 def to_block(type=:chain) CommandBlock.new self, type, 0 end |
#to_minecart ⇒ Object
28 29 30 |
# File 'lib/diamond-lang/helpers/command.rb', line 28 def to_minecart CommandBlockMinecart.new self end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/diamond-lang/helpers/command.rb', line 22 def to_s [@command, *@arguments].join " " end |