Class: ClientElement

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/liveviews/page-websocket.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#selectorObject

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