Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/ext/array.rb,
lib/fathom/archive/n3.rb,
lib/fathom/archive/noodle.rb
Instance Method Summary collapse
- #expand(array) ⇒ Object
- #give(sym, array = Array.new(self.size, 1/self.size)) ⇒ Object
- #given(sym, index) ⇒ Object
- #givens ⇒ Object
- #rand ⇒ Object
Instance Method Details
#expand(array) ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'lib/fathom/archive/n3.rb', line 2 def (array) return array.map{|e| [e]} if self.empty? array.inject([]) do |list, other_e| self.each do |e| list << [e,other_e].flatten end list end end |
#give(sym, array = Array.new(self.size, 1/self.size)) ⇒ Object
53 54 55 |
# File 'lib/fathom/archive/noodle.rb', line 53 def give(sym, array=Array.new(self.size, 1/self.size)) self.givens[sym] = array end |
#given(sym, index) ⇒ Object
57 58 59 |
# File 'lib/fathom/archive/noodle.rb', line 57 def given(sym, index) self.givens[sym][index] end |
#givens ⇒ Object
49 50 51 |
# File 'lib/fathom/archive/noodle.rb', line 49 def givens @givens ||= {} end |
#rand ⇒ Object
2 3 4 |
# File 'lib/ext/array.rb', line 2 def rand self[Kernel.rand(self.length)] end |