Class: Alexandria::BookProviders::Preferences::Variable

Inherits:
Object
  • Object
show all
Defined in:
lib/alexandria/book_providers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider, name, description, default_value, possible_values = nil, mandatory = true) ⇒ Variable

Returns a new instance of Variable.



139
140
141
142
143
144
145
146
147
148
# File 'lib/alexandria/book_providers.rb', line 139

def initialize(provider, name, description, default_value,
               possible_values = nil, mandatory = true)

  @provider = provider
  @name = name
  @description = description
  @value = default_value
  @possible_values = possible_values
  @mandatory = mandatory
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



135
136
137
# File 'lib/alexandria/book_providers.rb', line 135

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



135
136
137
# File 'lib/alexandria/book_providers.rb', line 135

def name
  @name
end

#possible_valuesObject (readonly)

Returns the value of attribute possible_values.



135
136
137
# File 'lib/alexandria/book_providers.rb', line 135

def possible_values
  @possible_values
end

#valueObject

Returns the value of attribute value.



137
138
139
# File 'lib/alexandria/book_providers.rb', line 137

def value
  @value
end

Instance Method Details

#default_value=(new_value) ⇒ Object



150
151
152
# File 'lib/alexandria/book_providers.rb', line 150

def default_value=(new_value)
  self.value = new_value
end

#mandatory?Boolean

Returns:

  • (Boolean)


164
165
166
# File 'lib/alexandria/book_providers.rb', line 164

def mandatory?
  @mandatory
end

#new_value=(new_value) ⇒ Object



154
155
156
157
158
# File 'lib/alexandria/book_providers.rb', line 154

def new_value=(new_value)
  name = @provider.variable_name(self)
  Alexandria::Preferences.instance.set_variable(name, new_value)
  self.value = new_value
end

#provider_nameObject



160
161
162
# File 'lib/alexandria/book_providers.rb', line 160

def provider_name
  @provider.name.downcase
end