class Alexandria::BookProviders::AbstractProvider
Attributes
fullname[RW]
name[RW]
prefs[R]
Public Class Methods
abstract?()
click to toggle source
# File lib/alexandria/book_providers.rb, line 270 def self.abstract? !included_modules.include?(Singleton) end
new(name, fullname = nil)
click to toggle source
# File lib/alexandria/book_providers.rb, line 202 def initialize(name, fullname = nil) @name = name @fullname = (fullname || name) @prefs = Preferences.new(self) @prefs.add("enabled", _("Enabled"), true, [true, false]) end
unabstract()
click to toggle source
FIXME: Clean up this complex abstract/concrete class system
# File lib/alexandria/book_providers.rb, line 279 def self.unabstract include Singleton undef_method :reinitialize undef_method :name= undef_method :fullname= undef_method :remove end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/alexandria/book_providers.rb, line 274 def <=>(other) fullname <=> other.fullname end
abstract?()
click to toggle source
# File lib/alexandria/book_providers.rb, line 266 def abstract? self.class.abstract? end
action_name()
click to toggle source
# File lib/alexandria/ui/init.rb, line 57 def action_name "At" + name end
enabled()
click to toggle source
# File lib/alexandria/book_providers.rb, line 209 def enabled @prefs["enabled"] end
reinitialize(fullname)
click to toggle source
# File lib/alexandria/book_providers.rb, line 218 def reinitialize(fullname) @name = "#{name}_#{fullname.hash}" @fullname = fullname prefs = Alexandria::Preferences.instance ary = prefs.get_variable :abstract_providers ary ||= [] ary << @name prefs.set_variable :abstract_providers, ary message = variable_name("name") prefs.set_variable(message, @fullname) end
remove()
click to toggle source
# File lib/alexandria/book_providers.rb, line 230 def remove prefs = Alexandria::Preferences.instance if (ary = prefs.get_variable :abstract_providers) ary.delete(@name) prefs.set_variable :abstract_providers, ary end if (ary = prefs.providers_priority) && ary.include?(@name) ary.delete(@name) prefs.providers_priority = ary end self.prefs.each do |variable| name = variable_name(variable) prefs.remove_preference(name) end name = variable_name("name") prefs.remove_preference(name) prefs.save! end
toggle_enabled()
click to toggle source
# File lib/alexandria/book_providers.rb, line 213 def toggle_enabled old_value = enabled @prefs.variable_named("enabled").new_value = !old_value end
transport()
click to toggle source
# File lib/alexandria/book_providers.rb, line 261 def transport config = Alexandria::Preferences.instance.http_proxy_config config ? Net::HTTP.Proxy(*config) : Net::HTTP end
variable_name(object)
click to toggle source
# File lib/alexandria/book_providers.rb, line 249 def variable_name(object) s = case object when String object when Preferences::Variable object.name else raise end @name.downcase + "_" + s end