class Alexandria::BookProviders::Preferences

Public Class Methods

new(provider) click to toggle source
# File lib/alexandria/book_providers.rb, line 130
def initialize(provider)
  @provider = provider
end

Public Instance Methods

[](obj) click to toggle source
Calls superclass method
# File lib/alexandria/book_providers.rb, line 173
def [](obj)
  case obj
  when String
    var = variable_named(obj)
    var ? var.value : nil
  when Integer
    super(obj)
  end
end
add(*args) click to toggle source
# File lib/alexandria/book_providers.rb, line 169
def add(*args)
  self << Variable.new(@provider, *args)
end
read() click to toggle source
# File lib/alexandria/book_providers.rb, line 187
def read
  each do |var|
    name = @provider.variable_name(var)
    val = Alexandria::Preferences.instance.get_variable(name)
    var.value = val unless val.nil? || ((val == "") && var.mandatory?)
  end
end
variable_named(name) click to toggle source
# File lib/alexandria/book_providers.rb, line 183
def variable_named(name)
  find { |var| var.name == name }
end