Class: DiamondLang::Helpers::TargetSelector

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variable, arguments = {}) ⇒ TargetSelector

Returns a new instance of TargetSelector.



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

def initialize(variable, arguments={})
  @variable, @arguments = "@#{variable}", arguments
end

Instance Attribute Details

#argumentsObject

Returns the value of attribute arguments.



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

def arguments
  @arguments
end

Instance Method Details

#<<(arguments) ⇒ Object



8
9
10
# File 'lib/diamond-lang/helpers/target_selector.rb', line 8

def <<(arguments)
  @arguments = @arguments.merge arguments
end

#mc_argsObject



19
20
21
# File 'lib/diamond-lang/helpers/target_selector.rb', line 19

def mc_args
  @arguments.map { |arg, val| val.to_arg arg }.join ','
end

#to_sObject Also known as: inspect



11
12
13
14
15
16
17
# File 'lib/diamond-lang/helpers/target_selector.rb', line 11

def to_s
  if @arguments.empty?
    @variable
  else
    @variable + "[" + mc_args + "]"
  end
end