Class: RubyApp::Element::Event
Direct Known Subclasses
ExceptionEvent, RubyApp::Elements::Base::BaseDialog::HiddenEvent, RubyApp::Elements::Base::BaseDialog::ShownEvent, RubyApp::Elements::Base::BasePage::LoadedEvent, RubyApp::Elements::Base::BasePage::TriggeredEvent, RubyApp::Elements::Calendars::Base::BaseMonth::ChangedEvent, RubyApp::Elements::Calendars::Base::BaseMonth::MovedEvent, RubyApp::Elements::Click::ClickedEvent, RubyApp::Elements::Input::ChangedEvent, RubyApp::Elements::List::ClickedEvent, RubyApp::Elements::Markdown::ClickedEvent, RubyApp::Elements::Navigation::Base::BaseBreadcrumbs::ClickedEvent, RubyApp::Elements::Navigation::PageLink::ClickedEvent
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
localize, translate
Constructor Details
#initialize(data = nil) ⇒ Event
Returns a new instance of Event.
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/ruby_app/element.rb', line 29
def initialize(data = nil)
if data
@session_id = data['session_id']
@now = Time.parse(data['now'])
@source = RubyApp::Element.get_element(data['source_id'])
else
@session_id = nil
@now = Time.now
@source = nil
end
@statements = []
end
|
Instance Attribute Details
#now ⇒ Object
Returns the value of attribute now.
27
28
29
|
# File 'lib/ruby_app/element.rb', line 27
def now
@now
end
|
#session_id ⇒ Object
Returns the value of attribute session_id.
27
28
29
|
# File 'lib/ruby_app/element.rb', line 27
def session_id
@session_id
end
|
#source ⇒ Object
Returns the value of attribute source.
27
28
29
|
# File 'lib/ruby_app/element.rb', line 27
def source
@source
end
|
Class Method Details
.from_hash(data) ⇒ Object
116
117
118
|
# File 'lib/ruby_app/element.rb', line 116
def self.from_hash(data)
eval(data['_class']).new(data)
end
|
Instance Method Details
#add_class(selector, _class) ⇒ Object
79
80
81
|
# File 'lib/ruby_app/element.rb', line 79
def add_class(selector, _class)
execute("RubyApp.addClass(#{selector.to_json}, #{_class.to_json});")
end
|
#alert(message) ⇒ Object
55
56
57
|
# File 'lib/ruby_app/element.rb', line 55
def alert(message)
execute("RubyApp.alert(#{message.to_json});")
end
|
#confirm_refresh(message) ⇒ Object
63
64
65
|
# File 'lib/ruby_app/element.rb', line 63
def confirm_refresh(message)
execute("RubyApp.confirmRefresh(#{message.to_json});")
end
|
#execute(statement) ⇒ Object
103
104
105
|
# File 'lib/ruby_app/element.rb', line 103
def execute(statement)
@statements << statement
end
|
#go(url) ⇒ Object
95
96
97
|
# File 'lib/ruby_app/element.rb', line 95
def go(url)
execute("RubyApp.go(#{url.to_json});")
end
|
#hide_dialog(dialog) ⇒ Object
71
72
73
|
# File 'lib/ruby_app/element.rb', line 71
def hide_dialog(dialog)
execute("RubyApp.hideDialog('#{dialog.element_id}');")
end
|
#log(message) ⇒ Object
51
52
53
|
# File 'lib/ruby_app/element.rb', line 51
def log(message)
execute("RubyApp.log(#{message.to_json});")
end
|
#refresh ⇒ Object
59
60
61
|
# File 'lib/ruby_app/element.rb', line 59
def refresh
execute("RubyApp.refresh();")
end
|
#remove_class(selector, _class) ⇒ Object
83
84
85
|
# File 'lib/ruby_app/element.rb', line 83
def remove_class(selector, _class)
execute("RubyApp.removeClass(#{selector.to_json}, #{_class.to_json});")
end
|
#set_cookie(name, value, expires = Time.now + 365*24*60*60) ⇒ Object
99
100
101
|
# File 'lib/ruby_app/element.rb', line 99
def set_cookie(name, value, expires = Time.now + 365*24*60*60)
execute("RubyApp.setCookie(#{name.to_json}, #{value.to_json}, new Date(#{expires.year}, #{expires.month - 1}, #{expires.day}, #{expires.hour}, #{expires.min}, #{expires.sec}));")
end
|
#show_dialog(dialog) ⇒ Object
67
68
69
|
# File 'lib/ruby_app/element.rb', line 67
def show_dialog(dialog)
execute("RubyApp.showDialog('#{dialog.element_id}');")
end
|
#to_hash ⇒ Object
107
108
109
110
111
112
113
114
|
# File 'lib/ruby_app/element.rb', line 107
def to_hash
{
'_class' => self.class.to_s,
'now' => @now,
'source_id' => @source ? @source.element_id : nil,
'statements' => @statements
}
end
|
#today ⇒ Object
42
43
44
|
# File 'lib/ruby_app/element.rb', line 42
def today
@now.send(:to_date)
end
|
#update_element(element) ⇒ Object
75
76
77
|
# File 'lib/ruby_app/element.rb', line 75
def update_element(element)
execute("RubyApp.updateElement('#{element.element_id}');")
end
|
#update_text(selector, value) ⇒ Object
87
88
89
|
# File 'lib/ruby_app/element.rb', line 87
def update_text(selector, value)
execute("RubyApp.updateText(#{selector.to_json}, #{value.to_json});")
end
|
#update_value(selector, value) ⇒ Object
91
92
93
|
# File 'lib/ruby_app/element.rb', line 91
def update_value(selector, value)
execute("RubyApp.updateValue(#{selector.to_json}, #{value.to_json});")
end
|