Class: FirefoxJson::Session::Window
- Inherits:
-
Base
- Object
- Base
- FirefoxJson::Session::Window
show all
- Defined in:
- lib/firefox-json/session.rb
Overview
A collection of tabs, both current and previous
Instance Attribute Summary collapse
Attributes inherited from Base
#path
Instance Method Summary
collapse
Methods inherited from Base
children, choose_for, #dump, #eql?, inherited, #inspect, mattr_accessor, #reload, required_key=, #save, set_collection
Constructor Details
#initialize(data, is_closed = false) ⇒ Window
Returns a new instance of Window.
221
222
223
224
|
# File 'lib/firefox-json/session.rb', line 221
def initialize data, is_closed = false
@is_closed = is_closed
setup data
end
|
Instance Attribute Details
#is_closed ⇒ Object
Returns the value of attribute is_closed.
218
219
220
|
# File 'lib/firefox-json/session.rb', line 218
def is_closed
@is_closed
end
|
Instance Method Details
#by_domain ⇒ Object
238
239
240
|
# File 'lib/firefox-json/session.rb', line 238
def by_domain
tabs.map(&:selected_domain).reduce(Hash.new(0)) {|h,host| h[host]+=1; h}.sort_by {|_,v| -v}
end
|
#current_urls ⇒ Object
230
231
232
|
# File 'lib/firefox-json/session.rb', line 230
def current_urls
tabs.map(&:selected_url)
end
|
#hash ⇒ Object
226
227
228
|
# File 'lib/firefox-json/session.rb', line 226
def hash
tabs.hash
end
|
#selected_title ⇒ Object
234
235
236
|
# File 'lib/firefox-json/session.rb', line 234
def selected_title
selected.selected.title
end
|
#to_s ⇒ Object
242
243
244
|
# File 'lib/firefox-json/session.rb', line 242
def to_s
"#<FirefoxJson::Window#{' closed!' if is_closed} tabs=#{tabs.size}#{' closed='+closed_tabs.size.to_s if closed_tabs.size>0} selected=\"#{selected_title}\">"
end
|