Class: DiamondLang::CommandChain

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ CommandChain

Returns a new instance of CommandChain.



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

def initialize(parent)
  @parent = parent
  @commands = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



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

def method_missing(name, *args, &block)
  @commands << Helpers::Command.new(name.to_s.downcase, args, &block)
end

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands.



5
6
7
# File 'lib/diamond-lang/command_chain.rb', line 5

def commands
  @commands
end

Instance Method Details

#to_minecartsObject



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

def to_minecarts
  self.commands.map{|command| command.to_minecart}
end