Class: EngineOfWar::Recommendation
- Inherits:
-
Object
- Object
- EngineOfWar::Recommendation
show all
- Defined in:
- lib/engine_of_war/recommendation.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Recommendation.
6
7
8
|
# File 'lib/engine_of_war/recommendation.rb', line 6
def initialize(values = {})
@values = HashWithIndifferentAccess.new(values)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/engine_of_war/recommendation.rb', line 10
def method_missing(*args, &block)
if key = args.first and @values.has_key?(key)
@values[key]
else
raise NoMethodError.new("#{key} not in #{@values.inspect}")
end
end
|
Class Method Details
.random ⇒ Object
2
3
4
|
# File 'lib/engine_of_war/recommendation.rb', line 2
def self.random
new(recommendations_data.sample)
end
|
Instance Method Details
#inspect ⇒ Object
18
19
20
|
# File 'lib/engine_of_war/recommendation.rb', line 18
def inspect
"Recommendation: #{@values.inspect}"
end
|
#to_s ⇒ Object
22
|
# File 'lib/engine_of_war/recommendation.rb', line 22
def to_s; inspect; end
|