Class: Element
- Inherits:
-
Object
- Object
- Element
- Defined in:
- lib/shot_mvc/element.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Associated ApplicationInstance.
-
#selector ⇒ Object
jQuery Selector.
Class Method Summary collapse
Instance Method Summary collapse
- #html=(html) ⇒ Object
-
#initialize(selector) ⇒ Element
constructor
A new instance of Element.
- #jq(method, parameters = {}) ⇒ Object
- #render(template, data = nil) ⇒ Object
- #text=(text) ⇒ Object
Constructor Details
#initialize(selector) ⇒ Element
Returns a new instance of Element.
24 25 26 27 |
# File 'lib/shot_mvc/element.rb', line 24 def initialize(selector) @selector = selector @app = nil end |
Instance Attribute Details
#app ⇒ Object
Associated ApplicationInstance
16 17 18 |
# File 'lib/shot_mvc/element.rb', line 16 def app @app end |
#selector ⇒ Object
jQuery Selector
13 14 15 |
# File 'lib/shot_mvc/element.rb', line 13 def selector @selector end |
Class Method Details
Instance Method Details
#html=(html) ⇒ Object
39 40 41 |
# File 'lib/shot_mvc/element.rb', line 39 def html=(html) self.jq 'html', [html] end |
#jq(method, parameters = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/shot_mvc/element.rb', line 29 def jq(method, parameters = {}) unless app == nil @app.emit 'jq', { 'selector' => @selector, 'method' => method, 'parameters' => [parameters] } end end |
#render(template, data = nil) ⇒ Object
47 48 49 50 51 |
# File 'lib/shot_mvc/element.rb', line 47 def render(template, data = nil) template = @app.get 'template', template template.data = data unless data == nil self.html = template.render end |
#text=(text) ⇒ Object
43 44 45 |
# File 'lib/shot_mvc/element.rb', line 43 def text=(text) self.jq 'text', [text] end |