Class: Mack::JavaScript::Selector

Inherits:
Object
  • Object
show all
Includes:
ViewHelpers::StringHelpers
Defined in:
lib/mack-javascript/helpers/script_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ViewHelpers::StringHelpers

#escape_javascript

Constructor Details

#initialize(generator, *sel) ⇒ Selector

Returns a new instance of Selector.



153
154
155
156
157
158
# File 'lib/mack-javascript/helpers/script_generator.rb', line 153

def initialize(generator, *sel)
  @generator = generator
  @session_id = generator.session_id
  @selector = sel.first == 'this' ? 'this' : build_multiple_selector_string(sel)
  @generator << select
end

Instance Attribute Details

#session_idObject (readonly)

Returns the value of attribute session_id.



151
152
153
# File 'lib/mack-javascript/helpers/script_generator.rb', line 151

def session_id
  @session_id
end

Instance Method Details

#add(statement, options = {}) ⇒ Object



160
161
162
163
# File 'lib/mack-javascript/helpers/script_generator.rb', line 160

def add(statement, options = {})
  @generator.<<(".#{statement}", :add_to_last => true)
  self
end

#to_sObject



165
166
167
# File 'lib/mack-javascript/helpers/script_generator.rb', line 165

def to_s
  @generator.to_s
end