Class: DiamondLang::Helpers::TargetSelector
- Defined in:
- lib/diamond-lang/helpers/target_selector.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
Returns the value of attribute arguments.
Instance Method Summary collapse
- #<<(arguments) ⇒ Object
-
#initialize(variable, arguments = {}) ⇒ TargetSelector
constructor
A new instance of TargetSelector.
- #mc_args ⇒ Object
- #to_s ⇒ Object (also: #inspect)
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
#arguments ⇒ Object
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_args ⇒ Object
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_s ⇒ Object 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 |