Class: RubyApp::Element::Event
- Inherits:
-
Object
- Object
- RubyApp::Element::Event
show all
- Defined in:
- lib/ruby_app/element.rb
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::Base::BasePage::UnloadedEvent, 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
Constructor Details
#initialize(data = nil) ⇒ Event
Returns a new instance of Event.
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/ruby_app/element.rb', line 29
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.
27
28
29
|
# File 'lib/ruby_app/element.rb', line 27
def now
@now
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
105
106
107
|
# File 'lib/ruby_app/element.rb', line 105
def self.from_hash(data)
eval(data['_class']).new(data)
end
|
Instance Method Details
#add_class(selector, _class) ⇒ Object
68
69
70
|
# File 'lib/ruby_app/element.rb', line 68
def add_class(selector, _class)
execute("RubyApp.add_class(#{selector.to_json}, #{_class.to_json});")
end
|
#alert(message) ⇒ Object
48
49
50
|
# File 'lib/ruby_app/element.rb', line 48
def alert(message)
execute("RubyApp.alert(#{message.to_json});")
end
|
#execute(statement) ⇒ Object
92
93
94
|
# File 'lib/ruby_app/element.rb', line 92
def execute(statement)
@statements << statement
end
|
#go(url) ⇒ Object
84
85
86
|
# File 'lib/ruby_app/element.rb', line 84
def go(url)
execute("RubyApp.go(#{url.to_json});")
end
|
#hide(dialog) ⇒ Object
60
61
62
|
# File 'lib/ruby_app/element.rb', line 60
def hide(dialog)
execute("RubyApp.hide('#{dialog.element_id}');")
end
|
#process! ⇒ Object
44
45
46
|
# File 'lib/ruby_app/element.rb', line 44
def process!
source.send(:on_event, self)
end
|
#refresh ⇒ Object
52
53
54
|
# File 'lib/ruby_app/element.rb', line 52
def refresh
execute("RubyApp.refresh();")
end
|
#remove_class(selector, _class) ⇒ Object
72
73
74
|
# File 'lib/ruby_app/element.rb', line 72
def remove_class(selector, _class)
execute("RubyApp.remove_class(#{selector.to_json}, #{_class.to_json});")
end
|
#set_cookie(name, value, expires = Time.now + 365*24*60*60) ⇒ Object
88
89
90
|
# File 'lib/ruby_app/element.rb', line 88
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) ⇒ Object
56
57
58
|
# File 'lib/ruby_app/element.rb', line 56
def show(dialog)
execute("RubyApp.show('#{dialog.element_id}');")
end
|
#to_hash ⇒ Object
96
97
98
99
100
101
102
103
|
# File 'lib/ruby_app/element.rb', line 96
def to_hash
{
'_class' => self.class.to_s,
'now' => @now,
'source_id' => @source ? @source.element_id : nil,
'statements' => @statements
}
end
|
#today ⇒ Object
40
41
42
|
# File 'lib/ruby_app/element.rb', line 40
def today
@now.send(:to_date)
end
|
#update_element(element) ⇒ Object
64
65
66
|
# File 'lib/ruby_app/element.rb', line 64
def update_element(element)
execute("RubyApp.updateElement('#{element.element_id}');")
end
|
#update_text(selector, value) ⇒ Object
76
77
78
|
# File 'lib/ruby_app/element.rb', line 76
def update_text(selector, value)
execute("RubyApp.updateText(#{selector.to_json}, #{value.to_json});")
end
|
#update_value(selector, value) ⇒ Object
80
81
82
|
# File 'lib/ruby_app/element.rb', line 80
def update_value(selector, value)
execute("RubyApp.updateValue(#{selector.to_json}, #{value.to_json});")
end
|