Class: FirefoxJson::Session::Tab
- Inherits:
-
Base
- Object
- Base
- FirefoxJson::Session::Tab
show all
- Defined in:
- lib/firefox-json/session.rb
Overview
A tab collects all its history and knows whether it’s closed or not
Instance Attribute Summary collapse
Attributes inherited from Base
#path
Instance Method Summary
collapse
Methods inherited from Base
children, choose_for, #eql?, inherited, #inspect, mattr_accessor, #reload, required_key=, #save, set_collection
Constructor Details
#initialize(data, is_closed) ⇒ Tab
is_closed passed from Window and means the real data is inside the ‘state’ key
182
183
184
185
186
187
188
189
|
# File 'lib/firefox-json/session.rb', line 182
def initialize data, is_closed
@is_closed = is_closed
if is_closed
@closed_data = data.reject {|key,_v| 'state' == key}
end
tab_state = is_closed ? data['state'] : data
setup tab_state
end
|
Instance Attribute Details
#is_closed ⇒ Object
Returns the value of attribute is_closed.
178
179
180
|
# File 'lib/firefox-json/session.rb', line 178
def is_closed
@is_closed
end
|
Instance Method Details
#dump ⇒ Object
195
196
197
|
# File 'lib/firefox-json/session.rb', line 195
def dump
is_closed ? @closed_data.merge('state' => super) : super
end
|
#hash ⇒ Object
191
192
193
|
# File 'lib/firefox-json/session.rb', line 191
def hash
selected_url.hash
end
|
#selected_domain ⇒ Object
207
208
209
|
# File 'lib/firefox-json/session.rb', line 207
def selected_domain
selected&.domain
end
|
#selected_title ⇒ Object
199
200
201
|
# File 'lib/firefox-json/session.rb', line 199
def selected_title
selected&.title
end
|
#selected_url ⇒ Object
203
204
205
|
# File 'lib/firefox-json/session.rb', line 203
def selected_url
selected&.url
end
|
#to_s ⇒ Object
211
212
213
|
# File 'lib/firefox-json/session.rb', line 211
def to_s
"#<FirefoxJson::Tab#{' closed!' if is_closed} entries=#{entries.size} selected=\"#{selected_title}\">"
end
|