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.
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/ruby_app/element.rb', line 30
def initialize(data = nil)
if data
@now = Time.parse(data['now'])
@source = RubyApp::Element.get_element(data['source_id'])
else
@now = Time.now
@source = nil
end
@statements = []
end
|
Instance Attribute Details
#now ⇒ Object
Returns the value of attribute now.
28
29
30
|
# File 'lib/ruby_app/element.rb', line 28
def now
@now
end
|
#source ⇒ Object
Returns the value of attribute source.
28
29
30
|
# File 'lib/ruby_app/element.rb', line 28
def source
@source
end
|
Class Method Details
.from_hash(data) ⇒ Object
114
115
116
|
# File 'lib/ruby_app/element.rb', line 114
def self.from_hash(data)
eval(data['_class']).new(data)
end
|
Instance Method Details
#add_class(selector, _class) ⇒ Object
77
78
79
|
# File 'lib/ruby_app/element.rb', line 77
def add_class(selector, _class)
execute("RubyApp.addClass(#{selector.to_json}, #{_class.to_json});")
end
|
#alert(message) ⇒ Object
53
54
55
|
# File 'lib/ruby_app/element.rb', line 53
def alert(message)
execute("RubyApp.alert(#{message.to_json});")
end
|
#confirm_refresh(message) ⇒ Object
61
62
63
|
# File 'lib/ruby_app/element.rb', line 61
def confirm_refresh(message)
execute("RubyApp.confirm_refresh(#{message.to_json});")
end
|
#execute(statement) ⇒ Object
101
102
103
|
# File 'lib/ruby_app/element.rb', line 101
def execute(statement)
@statements << statement
end
|
#go(url) ⇒ Object
93
94
95
|
# File 'lib/ruby_app/element.rb', line 93
def go(url)
execute("RubyApp.go(#{url.to_json});")
end
|
#hide_dialog(dialog) ⇒ Object
69
70
71
|
# File 'lib/ruby_app/element.rb', line 69
def hide_dialog(dialog)
execute("RubyApp.hideDialog('#{dialog.element_id}');")
end
|
#log(message) ⇒ Object
49
50
51
|
# File 'lib/ruby_app/element.rb', line 49
def log(message)
execute("RubyApp.log(#{message.to_json});")
end
|
#process! ⇒ Object
45
46
47
|
# File 'lib/ruby_app/element.rb', line 45
def process!
source.send(:on_event, self)
end
|
#refresh ⇒ Object
57
58
59
|
# File 'lib/ruby_app/element.rb', line 57
def refresh
execute("RubyApp.refresh();")
end
|
#remove_class(selector, _class) ⇒ Object
81
82
83
|
# File 'lib/ruby_app/element.rb', line 81
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
97
98
99
|
# File 'lib/ruby_app/element.rb', line 97
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
65
66
67
|
# File 'lib/ruby_app/element.rb', line 65
def show_dialog(dialog)
execute("RubyApp.showDialog('#{dialog.element_id}');")
end
|
#to_hash ⇒ Object
105
106
107
108
109
110
111
112
|
# File 'lib/ruby_app/element.rb', line 105
def to_hash
{
'_class' => self.class.to_s,
'now' => @now,
'source_id' => @source ? @source.element_id : nil,
'statements' => @statements
}
end
|
#today ⇒ Object
41
42
43
|
# File 'lib/ruby_app/element.rb', line 41
def today
@now.send(:to_date)
end
|
#update_element(element) ⇒ Object
73
74
75
|
# File 'lib/ruby_app/element.rb', line 73
def update_element(element)
execute("RubyApp.updateElement('#{element.element_id}');")
end
|
#update_text(selector, value) ⇒ Object
85
86
87
|
# File 'lib/ruby_app/element.rb', line 85
def update_text(selector, value)
execute("RubyApp.updateText(#{selector.to_json}, #{value.to_json});")
end
|
#update_value(selector, value) ⇒ Object
89
90
91
|
# File 'lib/ruby_app/element.rb', line 89
def update_value(selector, value)
execute("RubyApp.updateValue(#{selector.to_json}, #{value.to_json});")
end
|