Class: ClientElement
- Inherits:
-
Object
- Object
- ClientElement
- Defined in:
- lib/sinatra/liveviews/page-websocket.rb
Instance Attribute Summary collapse
-
#selector ⇒ Object
Returns the value of attribute selector.
Instance Method Summary collapse
- #execute(method, content) ⇒ Object
- #html=(s) ⇒ Object
-
#initialize(selector, client) ⇒ ClientElement
constructor
A new instance of ClientElement.
- #text=(s) ⇒ Object
Constructor Details
#initialize(selector, client) ⇒ ClientElement
Returns a new instance of ClientElement.
66 67 68 69 70 71 |
# File 'lib/sinatra/liveviews/page-websocket.rb', line 66 def initialize(selector, client) raise 'client must be a WebSocketHelper' unless client.is_a? WebSocketHelper @client = client self.selector = selector.to_s end |
Instance Attribute Details
#selector ⇒ Object
Returns the value of attribute selector.
64 65 66 |
# File 'lib/sinatra/liveviews/page-websocket.rb', line 64 def selector @selector end |
Instance Method Details
#execute(method, content) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/sinatra/liveviews/page-websocket.rb', line 73 def execute(method, content) @client.send('exec', { :selector => self.selector, :method => method, :content => content.to_s }) end |
#html=(s) ⇒ Object
85 86 87 |
# File 'lib/sinatra/liveviews/page-websocket.rb', line 85 def html=(s) self.execute 'html', s end |
#text=(s) ⇒ Object
81 82 83 |
# File 'lib/sinatra/liveviews/page-websocket.rb', line 81 def text=(s) self.execute 'text', s end |