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.



142
143
144
145
146
147
148
149
150
# File 'lib/alexandria/book_providers.rb', line 142

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.



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

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#possible_valuesObject (readonly)

Returns the value of attribute possible_values.



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

def possible_values
  @possible_values
end

#valueObject

Returns the value of attribute value.



140
141
142
# File 'lib/alexandria/book_providers.rb', line 140

def value
  @value
end

Instance Method Details

#default_value=(new_value) ⇒ Object



152
153
154
# File 'lib/alexandria/book_providers.rb', line 152

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

#mandatory?Boolean

Returns:

  • (Boolean)


166
167
168
# File 'lib/alexandria/book_providers.rb', line 166

def mandatory?
  @mandatory
end

#new_value=(new_value) ⇒ Object



156
157
158
159
160
# File 'lib/alexandria/book_providers.rb', line 156

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



162
163
164
# File 'lib/alexandria/book_providers.rb', line 162

def provider_name
  @provider.name.downcase
end