Class: Mack::JavaScript::Function
- Defined in:
- lib/mack-javascript/helpers/script_generator.rb
Instance Method Summary collapse
- #<<(*args) ⇒ Object
- #body {|@generator| ... } ⇒ Object
-
#initialize(session_id = nil, *args) ⇒ Function
constructor
A new instance of Function.
- #to_s ⇒ Object
Constructor Details
#initialize(session_id = nil, *args) ⇒ Function
Returns a new instance of Function.
174 175 176 177 178 179 180 181 |
# File 'lib/mack-javascript/helpers/script_generator.rb', line 174 def initialize(session_id = nil, *args) if args.first.is_a? Fixnum args = Array.new(args.first){|i| i + 1}.collect{|x| "obj#{x}"} end @session_id = session_id @arguments = args @generator = Mack::JavaScript::ScriptGenerator.new(session_id) end |
Instance Method Details
#<<(*args) ⇒ Object
183 184 185 186 |
# File 'lib/mack-javascript/helpers/script_generator.rb', line 183 def <<(*args) @generator << args to_s end |
#body {|@generator| ... } ⇒ Object
188 189 190 191 |
# File 'lib/mack-javascript/helpers/script_generator.rb', line 188 def body(&block) yield @generator to_s end |
#to_s ⇒ Object
193 194 195 |
# File 'lib/mack-javascript/helpers/script_generator.rb', line 193 def to_s "function(#{@arguments.join(', ')}){#{@generator.to_s}}" end |