Class: Fortune::P_abstract
- Inherits:
-
Object
- Object
- Fortune::P_abstract
- Defined in:
- lib/fortune/p_abstract.rb
Overview
Permutations
Direct Known Subclasses
A, C, C_repetition, Pn, Pn_repetition
Instance Attribute Summary collapse
-
#k ⇒ Object
Returns the value of attribute k.
-
#n ⇒ Object
Returns the value of attribute n.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(h, format = {:n => :elements, :k => :select}) ⇒ P_abstract
constructor
A new instance of P_abstract.
Constructor Details
#initialize(h, format = {:n => :elements, :k => :select}) ⇒ P_abstract
Returns a new instance of P_abstract.
7 8 9 10 11 12 |
# File 'lib/fortune/p_abstract.rb', line 7 def initialize(h, format = {:n => :elements, :k => :select}) raise ArgumentError.new("Error: arguments should be hash") unless h.is_a?(Hash) self.n = h[:n] || h[format[:n]] self.k = h[:k] || h[format[:k]] self.value = h end |
Instance Attribute Details
#k ⇒ Object
Returns the value of attribute k.
5 6 7 |
# File 'lib/fortune/p_abstract.rb', line 5 def k @k end |
#n ⇒ Object
Returns the value of attribute n.
5 6 7 |
# File 'lib/fortune/p_abstract.rb', line 5 def n @n end |
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'lib/fortune/p_abstract.rb', line 5 def value @value end |
Class Method Details
.calc(n) ⇒ Object
14 15 16 |
# File 'lib/fortune/p_abstract.rb', line 14 def self.calc(n) self.new(n).value end |